|
From: Markus H. <mar...@mh...> - 2008-01-23 16:47:27
|
Jo=E3o Henrique Freitas writes: > I have a problem in the function dbi=5Fresult=5Fget=5Fbinary=5Fcopy.= >=20 > That function call the dbi=5Fresult=5Fget=5Fbinary=5Fcopy=5Fidx. >=20 > In the code dbi=5Fresult.c on line 1310 and 1311. The size variable > always is 0 or a low value and malloc allocates insufficient space i= n > pointer to newblob. The result is in line 1316 , memcpy not works li= ke > expected. >=20 > And so I think that has a little bug in dbi=5Fresult=5Fget=5Fbinary=5F= copy=5Fidx. >=20 Your analysis is correct. The problem is caused by the improper use of the field index in the call to dbi=5Fresult=5Fget=5Ffield=5Flength=5Fidx(). libdbi uses a 0-based inde= x internally, but when an API function is called, we need to use the user-visible 1-based index instead. Therefore this call retrieved the size of an adjacent column, causing the blob to get truncated. I've checked in a fix (see the attached diff for reference). I've also checked in an extended version of your test=5Fdbi.c patch which covers all database engines and also fixes a few minor errors in your patch. I was a little surprised to learn that one of the API functions was not covered by a test. Thanks for getting this to my attention. regards, Markus |