[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-dev
Subject:    [sr-dev] git:master:71299f04: utils: fix format truncation warning
From:       Victor Seva <linuxmaniac () torreviejawireless ! org>
Date:       2018-09-28 12:42:52
Message-ID: E1g5s6e-0004ek-Cc () www ! kamailio ! org
[Download RAW message or body]

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


Author: Victor Seva <linuxmaniac@torreviejawireless.org>
Committer: Victor Seva <linuxmaniac@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);


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic