[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strtok_r in glibc 2.0.7 bugginess
Leif Johansson <leifj@matematik.su.se> writes:
> (when, oh when will the next one come along ;-)
Soon :-)
> on a rh5.2 box and it dumped core on startup. It looks like strtok_r
> is buggy in glibc-2.0.7 (redhat release 29).
I don't think it's broken but we're rather using it incorrectly.
> I tried to replace it with the roken version. However strtok_r.c was
> missing from lib/roken/Makefile.am. An easy fix.
It's only added to the makefile if it's not found while configuring.
> The original one dumped core on strtok_r("+"," \t",&pos)
> i.e when the string does not contain a token.
I think the error actually happens when using a constant string. Can
you try the appended patch and if it solves the problem for you?
/assar
Index: kdc/connect.c
===================================================================
RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/heimdal/kdc/connect.c,v
retrieving revision 1.45
diff -u -w -u -w -r1.45 connect.c
--- connect.c 1998/11/29 07:40:46 1.45
+++ connect.c 1999/01/30 15:52:48
@@ -102,12 +102,14 @@
}
static void
-parse_ports(char *str)
+parse_ports(const char *str)
{
char *pos = NULL;
char *p;
- p = strtok_r(str, " \t", &pos);
- while(p){
+ char *str_copy = strdup (str);
+
+ p = strtok_r(str_copy, " \t", &pos);
+ while(p != NULL) {
if(strcmp(p, "+") == 0) {
#ifdef HAVE_IPV6
add_standard_ports(AF_INET6);
@@ -136,6 +138,7 @@
p = strtok_r(NULL, " \t", &pos);
}
+ free (str_copy);
}
struct descr {