João Henrique Freitas writes: > I have a problem in the function dbi_result_get_binary_copy. > > That function call the dbi_result_get_binary_copy_idx. > > In the code dbi_result.c on line 1310 and 1311. The size variable > always is 0 or a low value and malloc allocates insufficient space in > pointer to newblob. The result is in line 1316 , memcpy not works like > expected. > > And so I think that has a little bug in dbi_result_get_binary_copy_idx. >
Your analysis is correct. The problem is caused by the improper use of the field index in the call to dbi_result_get_field_length_idx(). libdbi uses a 0-based index 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_dbi.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
dbi_result.c.diff
Description: diff
-- Markus Hoenicka [EMAIL PROTECTED] (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ libdbi-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libdbi-devel

