From 120115a9dcf529f58f1cf284068d79c8cc8ec11e Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Sun, 17 Jun 2018 19:06:52 -0700 Subject: gpsmon: fix NULL pointer dereference. Thanks to a report from --- gpsmon.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gpsmon.c') 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, -- cgit v1.2.1