[sr-dev] git:master:71299f04: utils: fix format truncation warning

Victor Seva linuxmaniac at torreviejawireless.org
Fri Sep 28 14:42:52 CEST 2018


Module: kamailio
Branch: master
Commit: 71299f04850e52835fa59872403b541448a18145
URL: https://github.com/kamailio/kamailio/commit/71299f04850e52835fa59872403b541448a18145

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2018-09-28T14:42:44+02:00

utils: fix format truncation warning

> 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);
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---

Modified: src/modules/utils/conf.c

---

Diff:  https://github.com/kamailio/kamailio/commit/71299f04850e52835fa59872403b541448a18145.diff
Patch: https://github.com/kamailio/kamailio/commit/71299f04850e52835fa59872403b541448a18145.patch

---

diff --git a/src/modules/utils/conf.c b/src/modules/utils/conf.c
index 822cd9206d..4836afa9e4 100644
--- a/src/modules/utils/conf.c
+++ b/src/modules/utils/conf.c
@@ -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);




More information about the sr-dev mailing list