From d0174994cbf43b0c2f17352f0ce4bb49acf8c45f Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 23 Nov 2014 16:32:22 +0000 Subject: [PATCH 1/2] Fix path buffer size --- dump1090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump1090.c b/dump1090.c index 00d907f..5642070 100644 --- a/dump1090.c +++ b/dump1090.c @@ -793,7 +793,7 @@ int main(int argc, char **argv) { #ifndef _WIN32 } else if (!strcmp(argv[j], "--write-json") && more) { ++j; - Modes.json_path = malloc(strlen(argv[j]) + 11); + Modes.json_path = malloc(strlen(argv[j]) + 15); strcpy(Modes.json_path, argv[j]); strcat(Modes.json_path, "/aircraft.json"); } else if (!strcmp(argv[j], "--write-json-every") && more) { From ebab2c0e1127aae044f5b77fe6ba8ec7e3bb51ac Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 23 Nov 2014 16:32:45 +0000 Subject: [PATCH 2/2] Create json files with mode 0644 - umask. mkstemp defaults to 0600 which is not so useful for serving the file. --- net_io.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net_io.c b/net_io.c index 85246fc..ad970b0 100644 --- a/net_io.c +++ b/net_io.c @@ -703,6 +703,7 @@ void modesWriteJson(const char *path) int fd; int len = 0; char *content; + mode_t mask; snprintf(tmppath, PATH_MAX, "%s.XXXXXX", path); tmppath[PATH_MAX-1] = 0; @@ -710,6 +711,10 @@ void modesWriteJson(const char *path) if (fd < 0) return; + mask = umask(0); + umask(mask); + fchmod(fd, 0644 & ~mask); + content = aircraftsToJson(&len); if (write(fd, content, len) != len) goto error_1;