Skip to content

Commit

Permalink
utils: fix format truncation warning
Browse files Browse the repository at this point in the history
> conf.c: In function 'update_filter':
> conf.c:211:31: warning: ':' directive output may be truncated writing 1 byte into a region of size between 0 and 1000 [-Wformat-truncation=]
>      snprintf(buf, BUFSIZE, "%s:%s", tmp, token);
>                                ^
> conf.c:211:5: note: 'snprintf' output 2 or more bytes (assuming 1002) into a destination of size 1000
>      snprintf(buf, BUFSIZE, "%s:%s", tmp, token);
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
linuxmaniac committed Sep 28, 2018
1 parent 93ff141 commit 71299f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/modules/utils/conf.c
Expand Up @@ -208,7 +208,9 @@ static int update_filter(int id, char *flist)
/* no special filter! */
if (buf[0]) {
strcpy(tmp, buf);
snprintf(buf, BUFSIZE, "%s:%s", tmp, token);
if(snprintf(buf, BUFSIZE, "%s:%s", tmp, token)>BUFSIZE) {
LM_BUG("output was truncated\n");
}
buf[BUFSIZE]='\0';
} else {
snprintf(buf, BUFSIZE, "%s", token);
Expand Down

0 comments on commit 71299f0

Please sign in to comment.