From: Sebastian Kemper Date: Sat, 3 Feb 2018 18:00:03 +0000 (+0100) Subject: FS-10939 mod_cdr_mongodb: fix format truncation warnings with gcc 7 X-Git-Tag: v1.8.1~3^2~236^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eded5965a4b26572aa254bab63771440934494bd;p=thirdparty%2Ffreeswitch.git FS-10939 mod_cdr_mongodb: fix format truncation warnings with gcc 7 gcc 7 complains about possible format truncation: mod_cdr_mongodb.c: In function 'my_on_reporting': mod_cdr_mongodb.c:242:45: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Werror=format-truncation=] snprintf(idx_buffer, sizeof(idx_buffer), "%d", callflow_idx); The char * idx_buffer has a size of 4 Bytes, and according to gcc's calculation it is possible that up to 11 Bytes might be copied into it via int bson_idx. This commit adds an extra 8 Bytes to char * idx_buffer, which silences the warnings. Signed-off-by: Sebastian Kemper --- diff --git a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c index cdd9d3390d..c253b48b63 100644 --- a/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c +++ b/src/mod/event_handlers/mod_cdr_mongodb/mod_cdr_mongodb.c @@ -141,7 +141,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) bson cdr; int is_b; int bson_idx, callflow_idx; - char idx_buffer[4]; + char idx_buffer[12]; char *tmp; if (globals.shutdown) {