🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #103

strstr broken in gdb-4.4/libiberty -- fix included

#103
From: Bruce Robert Larson
Date: Tue, 07 Apr 1992 02:45
54 lines
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);
        }
Technical Details
Message-ID: <9204070245.AA26821@ra.cs.umb.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.umb.edu!blarson

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.umb.edu!blarson
From: blarson@cs.umb.edu (Bruce Robert Larson)
Subject: strstr broken in gdb-4.4/libiberty -- fix included
Message-ID: <9204070245.AA26821@ra.cs.umb.edu>
Sender: gnulists@ai.mit.edu
Reply-To: Bruce R Larson <blarson%ires.com@cs.umb.edu>
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 7 Apr 1992 02:45:24 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 56