diff options
author | Gary E. Miller <gem@rellim.com> | 2018-06-17 19:06:52 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-06-17 19:06:52 -0700 |
commit | 120115a9dcf529f58f1cf284068d79c8cc8ec11e (patch) | |
tree | 69736d97924e334fb94eb79b675a91dadc91b74c /gpsmon.c | |
parent | e9bb70498c655518c7f2be9f5201e5125d69580f (diff) | |
download | gpsd-120115a9dcf529f58f1cf284068d79c8cc8ec11e.tar.gz |
gpsmon: fix NULL pointer dereference.
Thanks to a report from <alexc@sbrella.com>
Diffstat (limited to 'gpsmon.c')
-rw-r--r-- | gpsmon.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1298,9 +1298,16 @@ int main(int argc, char **argv) } if (serial) { - (void) strlcpy(session.gpsdata.dev.path, - source.device, - sizeof(session.gpsdata.dev.path)); + if (NULL == source.device) { + /* this can happen with "gpsmon /dev:dd" */ + (void) strlcpy(session.gpsdata.dev.path, + argv[optind], + sizeof(session.gpsdata.dev.path)); + } else { + (void) strlcpy(session.gpsdata.dev.path, + source.device, + sizeof(session.gpsdata.dev.path)); + } } else { if (strstr(source.server, "//") == 0) (void) strlcpy(session.gpsdata.dev.path, |