summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-06-17 19:06:52 -0700
committerGary E. Miller <gem@rellim.com>2018-06-17 19:06:52 -0700
commit120115a9dcf529f58f1cf284068d79c8cc8ec11e (patch)
tree69736d97924e334fb94eb79b675a91dadc91b74c /gpsmon.c
parente9bb70498c655518c7f2be9f5201e5125d69580f (diff)
downloadgpsd-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.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gpsmon.c b/gpsmon.c
index a495473d..941daec3 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -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,