diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-02-11 05:03:11 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-02-11 05:03:11 +0000 |
commit | 4ad14355839ab9d52bfaffa97ade93b8a62b7242 (patch) | |
tree | d3b11846e12bf05fca6bb0e8258bdad300101206 /libgps.c | |
parent | b30539012cfef093f7872e5fd5add92dddb26cf7 (diff) | |
download | gpsd-4ad14355839ab9d52bfaffa97ade93b8a62b7242.tar.gz |
Fixed potential core dump in C client handling of "K" responses.
Diffstat (limited to 'libgps.c')
-rw-r--r-- | libgps.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 @*/ |