From f98869fbb272a11751a1477e083898b8d41c94c6 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Tue, 9 Apr 2019 13:30:37 +0100 Subject: [PATCH] Clean up a couple of format truncation warnings Newer GCCs will warn about truncation in strncpy/snprintf etc, so re-jig things a bit to try and avoid it. --- keyd.c | 5 +++-- keydb_hkp.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/keyd.c b/keyd.c index c1c2d50..ad06e6a 100644 --- a/keyd.c +++ b/keyd.c @@ -609,7 +609,7 @@ int main(int argc, char *argv[]) { int fd = -1, maxfd, i, clients[MAX_CLIENTS]; fd_set rfds = { 0 }; /* Avoid scan-build false report for FD_SET */ - char sockname[1024]; + char sockname[100]; char *configfile = NULL; bool foreground = false; int optchar; @@ -655,7 +655,8 @@ int main(int argc, char *argv[]) } stats->started = time(NULL); - snprintf(sockname, 1023, "%s/%s", config.sock_dir, KEYD_SOCKET); + snprintf(sockname, sizeof(sockname) - 1, "%s/%s", + config.sock_dir, KEYD_SOCKET); fd = sock_init(sockname); if (fd != -1) { diff --git a/keydb_hkp.c b/keydb_hkp.c index d55551e..1465503 100644 --- a/keydb_hkp.c +++ b/keydb_hkp.c @@ -36,7 +36,7 @@ struct onak_hkp_dbctx { struct onak_db_config *config; /* Our DB config info */ CURL *curl; - char hkpbase[1024]; + char hkpbase[512]; }; static int hkp_parse_url(struct onak_hkp_dbctx *privctx, const char *url) -- 2.39.5