Menu

#56 Memory corruption in bytea handling

closed-fixed
libpq (15)
5
2003-11-10
2003-11-08
No

In unQuoteBytea the line (near the end)

sout[j] = (char)0;

in both unecessary (since Py_BuildValue for s# takes a
length)
and wrong. The memory allocated for sout is only the
same size as sin. If no characters require unquoting
in sin then this NUL ends up being placed _outside_ the
allocated memory and will corrupt things.

The line should be removed.

I suspect an extraneous NUL is also being appended in
libPQquoteBytea.

Discussion

  • Billy G. Allie

    Billy G. Allie - 2003-11-10

    Logged In: YES
    user_id=8500

    Yes, the sout[j] = 0 in unQuoteBytea is an error.

    There is a NUl being appended in libPQquoteBytea is
    extraneous, but does not cause a problem as it is accounted
    for in the size calculation of the buffer. Still it is not
    needed and has been removed.

    The code has been updated in CVS.

    Thanks for the bug report and fix James.

     
  • Billy G. Allie

    Billy G. Allie - 2003-11-10
    • assigned_to: nobody --> ballie01
    • status: open --> open-fixed
     
  • Billy G. Allie

    Billy G. Allie - 2003-11-10
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB