summaryrefslogtreecommitdiff
path: root/libgps.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-02-11 05:03:11 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-02-11 05:03:11 +0000
commit4ad14355839ab9d52bfaffa97ade93b8a62b7242 (patch)
treed3b11846e12bf05fca6bb0e8258bdad300101206 /libgps.c
parentb30539012cfef093f7872e5fd5add92dddb26cf7 (diff)
downloadgpsd-4ad14355839ab9d52bfaffa97ade93b8a62b7242.tar.gz
Fixed potential core dump in C client handling of "K" responses.
Diffstat (limited to 'libgps.c')
-rw-r--r--libgps.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libgps.c b/libgps.c
index 61ba77a1..c1508ebe 100644
--- a/libgps.c
+++ b/libgps.c
@@ -285,13 +285,14 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
/*@ -nullderef -nullpass -mustfreeonly -dependenttrans @*/
char *rc = strdup(sp);
char *sp2 = rc;
+ char *ns2 = ns;
gpsdata->ndevices = (int)strtol(sp2+2, &sp2, 10);
gpsdata->devicelist = (char **)calloc(
(size_t)gpsdata->ndevices,
sizeof(char **));
/*@ -nullstate -mustfreefresh @*/
- gpsdata->devicelist[i=0] = strdup(strtok_r(sp2+1, " \r\n", &ns));
- while ((sp2 = strtok_r(NULL, " \r\n", &ns)))
+ gpsdata->devicelist[i=0] = strdup(strtok_r(sp2+1, " \r\n", &ns2));
+ while ((sp2 = strtok_r(NULL, " \r\n", &ns2)))
gpsdata->devicelist[++i] = strdup(sp2);
free(rc);
/*@ +nullstate +mustfreefresh @*/