(parse_ports): copy the string before mishandling it with strtok_r

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5288 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-01-30 15:54:55 +00:00
parent 1ef2bdb96d
commit e9a23cb00b

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 1998 Kungliga Tekniska H<>gskolan * Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -102,12 +102,14 @@ add_standard_ports (int family)
} }
static void static void
parse_ports(char *str) parse_ports(const char *str)
{ {
char *pos = NULL; char *pos = NULL;
char *p; char *p;
p = strtok_r(str, " \t", &pos); char *str_copy = strdup (str);
while(p){
p = strtok_r(str_copy, " \t", &pos);
while(p != NULL) {
if(strcmp(p, "+") == 0) { if(strcmp(p, "+") == 0) {
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
add_standard_ports(AF_INET6); add_standard_ports(AF_INET6);
@@ -136,6 +138,7 @@ parse_ports(char *str)
p = strtok_r(NULL, " \t", &pos); p = strtok_r(NULL, " \t", &pos);
} }
free (str_copy);
} }
struct descr { struct descr {