Mailing List Archive



Back to the month index Back to the list index

Alex Tang (altitude@petrified.cic.net)
Mon, 6 Jan 1997 00:47:00 -0500 (EST)


Message-Id: <199701060547.AAA13261@petrified.cic.net>
Subject: Re: [mSQL] Another MSQL-2.0 B 1 UPDATE bug
Date: Mon, 6 Jan 1997 00:47:00 -0500 (EST)
From: Alex Tang <altitude@petrified.cic.net>

You scribbled...
> The following bug with UPDATE actually only happens when I have the
> "unofficial UPDATE patch" shown below applied to my sources:

<stuff deleted>

> The bug is that that AGE field has become NULL instead of being set to 55
>
> However, if the name() column in the table is created with size 13 or
> higher, then the bug doesn't happen.

Hi. I posted something about this yesterday. The problem is that the
UPDATE patch uses strcpy, which (on most if not all) systems will copy the
string from src to dest >and terminate the string with a null character<.

When you copy update the field with a string that is the exact size of
your field, you will write a null character over the first byte of the
next field (if there is any).

To fix the bug, use this patch included below which uses strncpy instead
of strcpy.

--- src/msql/table.c.orig Mon Dec 16 03:45:42 1996
+++ src/msql/table.c Tue Dec 24 09:43:09 1996
@@ -1337,7 +1337,7 @@
                                                         curField->name);
                                                return(-1);
                                         }
- strcpy(curField->value->val.charVal,cp);
+ strncpy(cp, curField->value->val.charVal, length);
                                         break;
 
                                 case TEXT_TYPE:

In another message, Steve Beer agreed with this patch.

Good Luck.

...alex...
--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!