summaryrefslogtreecommitdiff
path: root/gpxlogger.c
diff options
context:
space:
mode:
authorRobert Norris <rw_norris@hotmail.com>2017-02-20 01:44:50 +0000
committerFred Wright <fw@fwright.net>2017-02-20 15:35:49 -0800
commit9efa921f231bba7a428c5f5c5c1c8c392314b582 (patch)
treece5fb9e4e41b38aa4e59bb5f28975cc6f1c09068 /gpxlogger.c
parente2695bd13a933a87779ae0c71447ee81486daefa (diff)
downloadgpsd-9efa921f231bba7a428c5f5c5c1c8c392314b582.tar.gz
Ensure gpxlogger doesn't crash on bad filename
Need to ensure logfile is reset to 'stdout' when the specified output file is not available (e.g. no permission to write it) otherwise it is continued to be used when it is NULL and bad things happen. TESTED: Running as a normal user it doesn't crash with a bad filename: ./gpxlogger -f /root/CannotWriteHere.gpx Signed-off-by: Fred Wright <fw@fwright.net>
Diffstat (limited to 'gpxlogger.c')
-rw-r--r--gpxlogger.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gpxlogger.c b/gpxlogger.c
index a94c65d5..be889ae2 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -250,10 +250,12 @@ int main(int argc, char **argv)
}
fname[s] = '\0';;
logfile = fopen(fname, "w");
- if (logfile == NULL)
+ if (logfile == NULL) {
syslog(LOG_ERR,
"Failed to open %s: %s, logging to stdout.",
fname, strerror(errno));
+ logfile = stdout;
+ }
bailout:
free(fname);
break;