Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Bruce Robert Larson
Tue, 07 Apr 1992 02:45
strstr broken in gdb-4.4/libiberty -- fix included
Author: Bruce Robert Larson
Date: Tue, 07 Apr 1992 02:45
Date: Tue, 07 Apr 1992 02:45
54 lines
1830 bytes
1830 bytes
Bug report for: libiberty/strstr.c in gdb-4.4
Platform: all platforms. this is just an error.
Description: The following construction is used, in which
anything *other than* an exact match (of s2 in s1)
causes `stuff' to be executed. This is clearly
different from the authors intention.
if ( strcmp(s1, s2) )
stuff();
Something like this is appropriate
if ( strncmp(s1, s2, strlen(s2)) == 0 )
stuff();
Here is a context diff that fixes it.
Bruce
--
*** ORIG/strstr.c Mon Apr 6 21:12:57 1992
--- strstr.c Mon Apr 6 21:28:33 1992
***************
*** 47,58 ****
char *s1, *s2;
{
register char *p = s1 - 1;
extern char *strchr ();
extern int strcmp ();
while (0 != (p = strchr (p+1, *s2)))
{
! if (strcmp (p, s2))
{
return (p);
}
--- 47,61 ----
char *s1, *s2;
{
register char *p = s1 - 1;
+ register int len;
extern char *strchr ();
extern int strcmp ();
len = strlen(s2);
+
while (0 != (p = strchr (p+1, *s2)))
{
! if ( strncmp (p, s2, len) == 0 )
{
return (p);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads