From: Timo Kokkonen Date: Wed, 1 Mar 2023 16:28:40 +0000 (+0200) Subject: onewire_parser.c: Fix compiler warnings about string lengths X-Git-Url: http://git.itanic.dy.fi/?p=rrdd;a=commitdiff_plain;h=HEAD onewire_parser.c: Fix compiler warnings about string lengths Compilers are picky about not truncating the output when copying data with strncpy. From the static buffer sizes it sees the potential buffer truncation, so adjust the buffer sizes so that it is not possible to truncate buffers and leave the data unterminated. Signed-off-by: Timo Kokkonen --- diff --git a/onewire_parser.c b/onewire_parser.c index 07d359b..958cff9 100644 --- a/onewire_parser.c +++ b/onewire_parser.c @@ -107,7 +107,7 @@ static int parse_opts(const char *str, char *ow_path, size_t pathlen, break; /* Copy the onewire path without options */ - strncpy(ow_path, start_str, pathlen); + strncpy(ow_path, start_str, pathlen - 1); ow_path[str - start_str] = '\0'; /* Get the next non-space, which is where the argument begins */ @@ -130,7 +130,7 @@ static int parse_opts(const char *str, char *ow_path, size_t pathlen, static int make_uncached(char *path, size_t len) { int ret; - char p1[1024], p2[1024], *p = path; + char p1[1028], p2[1028], *p = path; if (strstr(path, "/uncached/")) return 0;