]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
use PATH_MAX
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 10 Oct 2019 15:53:58 +0000 (17:53 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Oct 2019 09:03:47 +0000 (11:03 +0200)
Include <limits.h> and use the PATH_MAX macro to define the length of
buffers containing paths to make it constistent. (It's not supposed to
fit all possible paths.)

logging.c
ntp_signd.c
sources.c
sysincl.h

index 9da14faa455fe8d7df6e0c72c8c63b8ad8fe2df6..9f89f196f64fd963ba6d62c3e73abcb2651a4b9f 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -266,7 +266,7 @@ LOG_FileWrite(LOG_FileID id, const char *format, ...)
     return;
 
   if (!logfiles[id].file) {
-    char filename[512], *logdir = CNF_GetLogDir();
+    char filename[PATH_MAX], *logdir = CNF_GetLogDir();
 
     if (logdir[0] == '\0') {
       LOG(LOGS_WARN, "logdir not specified");
index 600329eb2adb69e67b9bad6f4cf36faed83faa64..91434f222740a119e78c956716f87127632e6abf 100644 (file)
@@ -129,7 +129,7 @@ close_socket(void)
 static int
 open_socket(void)
 {
-  char path[1024];
+  char path[PATH_MAX];
 
   if (sock_fd != INVALID_SOCK_FD)
     return 1;
index 9ca937ed948b57eea050829109c360ee9f5408b0..5de8507f02dd978ea13d1b8791e2090ea52e1c5b 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -1153,7 +1153,7 @@ static
 FILE *open_dumpfile(SRC_Instance inst, const char *mode)
 {
   FILE *f;
-  char filename[1024], *dumpdir;
+  char filename[PATH_MAX], *dumpdir;
 
   dumpdir = CNF_GetDumpDir();
   if (dumpdir[0] == '\0') {
@@ -1225,7 +1225,7 @@ SRC_ReloadSources(void)
 void
 SRC_RemoveDumpFiles(void)
 {
-  char pattern[1024], name[64], *dumpdir, *s;
+  char pattern[PATH_MAX], name[64], *dumpdir, *s;
   IPAddr ip_addr;
   glob_t gl;
   size_t i;
index b27afa07e05bb8289a67a1690c9d06f15b887dc8..5c8866b1527e32ac39e966f464cdf23895d9ecbd 100644 (file)
--- a/sysincl.h
+++ b/sysincl.h
@@ -36,6 +36,7 @@
 #include <glob.h>
 #include <grp.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <math.h>
 #include <netinet/in.h>
 #include <pwd.h>