Paul J Stevens wrote:

Here's a suspect line possibly responsible for the binary chars in messageblks.


in db.c,db_insert_message_block_physmessage line 856:

        escaped_query = (char *) my_malloc(sizeof(char) * maxesclen);

I don't see a:

    memset(escaped_query,'\0',sizeof(char) * maxesclen);

around.

I don't think this causes the malfunction. The escaped_query string is printed to by snprintf() which adds a '\0' to the end. This last character is then overwritten by db_escape_query(), adding another '\0', which is again overwritten by the last snprintf(), which adds the last '\0'. So, the string is always terminated. I did add the memset() call though, because that should make it a lot safer to change this function in the future. And besides, it's just good practice to NULL all strings before using them.

Ilja

Reply via email to