diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index 743781cf4..5808635d8 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -1131,7 +1131,7 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) /* We have been provided with a string, check the contents. */ if (strchr(p, ' ')) { char *portals = strdup(p); - char *portal; + char *portal, *saveptr; if (!portals) { log_error("Memory error (internal_portal)"); @@ -1139,7 +1139,7 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) goto out_free; } - portal = strtok(portals, " "); + portal = strtok_r(portals, " ", &saveptr); while (portal != NULL) { if (!is_addr(portal)) { log_error("Invalid address supplied %s", portal); @@ -1147,7 +1147,7 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) res = -EINVAL; goto out_free; } - portal = strtok(NULL, " "); + portal = strtok_r(NULL, " ", &saveptr); } free(portals); } else { diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index bdb1382b9..d89e2a559 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -910,7 +910,7 @@ int main(int argc, char **argv) gid = strtoul(optarg, NULL, 0); break; case 'a': { - char *server_address, *token; + char *server_address, *token, *saveptr; int i = 0; server_address = strdup(optarg); @@ -919,14 +919,14 @@ int main(int argc, char **argv) exit(-1); } - token = strtok(server_address, " "); + token = strtok_r(server_address, " ", &saveptr); while ((i < ADDR_MAX) && token) { log_debug(0, "Address to listen: %s\n", token); server_addresses[i] = token; i++; - token = strtok(NULL, " "); + token = strtok_r(NULL, " ", &saveptr); } break; diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index a8dd41ea7..747509b0b 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -1029,14 +1029,15 @@ static bool on_internal_portal(struct connection *conn) char *portals = strdup(internal_portal); if (portals) { - char *portal = strtok(portals, " "); + char *saveptr; + char *portal = strtok_r(portals, " ", &saveptr); while (portal != NULL) { if (!strcmp(portal, conn->target_portal)) { free(portals); return true; } - portal = strtok(NULL, " "); + portal = strtok_r(NULL, " ", &saveptr); } free(portals); }