[martinea@IRO.UMontreal.CA] libc/1486: strsep access string beyond '\0'
Andreas Jaeger
aj@suse.de
Tue Dec 14 00:29:00 GMT 1999
We received the appended bug report. I've rewritten the test for our
own test framework (patch is appended). Tests 75, 77 and 80 fail now.
The documentation on strsep isn't totally clear to me. What should
happen in this case:
*one = '\0';
cp = one;
token = strsep(&cp, ",");
cp should be NULL and token also NULL?
Before I fix strsep, I'd like to know if my tests are ok. Could
somebody please double check the four new test cases and tell me if
they're ok?
Thanks,
Andreas
1999-12-14 Andreas Jaeger <aj@suse.de>
* string/tester.c (test_strsep): More tests for access beyond
the final NUL. The first two tests come from PR libc/1486 by
martinea@iro.umontreal.ca.
--- string/tester.c.~1~ Mon Oct 4 09:38:10 1999
+++ string/tester.c Tue Dec 14 09:22:23 1999
@@ -901,6 +901,25 @@
equal(strsep(&cp, "xy,"), "", 71);
check(strsep(&cp, "x,y") == NULL, 72);
check(strsep(&cp, ",xy") == NULL, 73); /* Persistence. */
+
+ cp = strcpy(one, "ABC");
+ one[4] = ':';
+ equal(strsep(&cp, "C"), "AB", 74); /* Access beyond NUL. */
+ check(strsep(&cp, ":") == NULL, 75);
+
+ cp = strcpy(one, "ABC");
+ one[4] = ':';
+ equal(strsep(&cp, "CD"), "AB", 76); /* Access beyond NUL. */
+ check(strsep(&cp, ":.") == NULL, 77);
+
+ cp = strcpy(one, "ABC"); /* No token in string. */
+ equal(strsep(&cp, ","), "ABC", 78);
+ check(cp == NULL, 79);
+
+ *one = '\0'; /* Empty string. */
+ cp = one;
+ check (strsep(&cp, ",") == NULL, 80);
+ check (cp == NULL, 81);
}
void
More information about the Libc-alpha
mailing list