diff --git a/dump1090.c b/dump1090.c index 11e563d..187efa6 100644 --- a/dump1090.c +++ b/dump1090.c @@ -832,7 +832,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) { diff --git a/net_io.c b/net_io.c index a5d1262..f896d73 100644 --- a/net_io.c +++ b/net_io.c @@ -734,6 +734,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; @@ -741,6 +742,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;