home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!ukma!wupost!decwrl!concert!sas!mozart.unx.sas.com!jamie
- From: jamie@cdevil.unx.sas.com (James Cooper)
- Subject: Re: Bug in SAS/C 6.0 library : strstr ()
- Originator: jamie@cdevil.unx.sas.com
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <Bxnw8z.CvD@unx.sas.com>
- Date: Fri, 13 Nov 1992 15:55:47 GMT
- References: <hadig.721653082@rama>
- Nntp-Posting-Host: cdevil.unx.sas.com
- Organization: SAS Institute Inc.
- Keywords: strstr, SAS/C 6.0
- Lines: 41
-
-
- In article <hadig.721653082@rama>, hadig@rama.informatik.rwth-aachen.de (Thomas Hadig) writes:
- >Hi,
- >
- >i have found a bug in the SAS/C Amiga 6.0 library function strstr :
- >
- >char * strstr (char *s1, char *s2);
- >
- >strstr searches the substring s2 in the string s1 and returns the
- >starting address of the substring s2 in s1 or NULL if not found.
- >
- >BUG :
- >
- >If you call strstr with an empty string s1, strstr will continue the
- >search instead of returning NULL.
-
- While strstr() is not an ANSI function, it *was* patterned after the
- other ANSI string functions.
-
- Basically, ANSI states that "If an array is accessed beyond the end of
- an object, the behavior is undefined." (Section 4.11.1, first para.)
-
- A NULL character array has no size, so trying to access a member of it
- at *all* is accessing "beyond the end" of it.
-
- I can put this in as an enhancement request for strstr(), but it can be
- argued that the current behavior is correct, at least according to ANSI
- specifications. Just check for NULL yourself before calling it.
-
- >[Example deleted]
- >
- >(Has been reported to EMITS)
-
- Thanks.
- --
- ---------------
- Jim Cooper
- (jamie@unx.sas.com) bix: jcooper
-
- Any opinions expressed herein are mine (Mine, all mine! Ha, ha, ha!),
- and not necessarily those of my employer.
-