From: Jonathan McDowell Date: Tue, 9 Apr 2019 12:30:37 +0000 (+0100) Subject: Clean up a couple of format truncation warnings X-Git-Tag: onak-0.6.0~72 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=f98869fbb272a11751a1477e083898b8d41c94c6;p=onak.git 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. --- 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)