[sr-dev] git:master:99896b1f: kex: use snprintf() for rpc memory mod stats

Daniel-Constantin Mierla miconda at gmail.com
Wed Apr 17 10:05:05 CEST 2019


Module: kamailio
Branch: master
Commit: 99896b1f05830777decaa70384982c14f45a8a60
URL: https://github.com/kamailio/kamailio/commit/99896b1f05830777decaa70384982c14f45a8a60

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-04-16T14:29:51+02:00

kex: use snprintf() for rpc memory mod stats

- safer to ensure it doesn't overflow the target buffer

---

Modified: src/modules/kex/mod_stats.c

---

Diff:  https://github.com/kamailio/kamailio/commit/99896b1f05830777decaa70384982c14f45a8a60.diff
Patch: https://github.com/kamailio/kamailio/commit/99896b1f05830777decaa70384982c14f45a8a60.patch

---

diff --git a/src/modules/kex/mod_stats.c b/src/modules/kex/mod_stats.c
index 5f8f0555cf..4dd5fb1095 100644
--- a/src/modules/kex/mod_stats.c
+++ b/src/modules/kex/mod_stats.c
@@ -105,7 +105,7 @@ static int rpc_mod_print(rpc_t *rpc, void *ctx, const char *mname,
 
 	while (iter) {
 		if (strcmp(mname, iter->mname) == 0) {
-			sprintf(buff, "%s(%ld)", iter->func, iter->line);
+			snprintf(buff, 128, "%s(%ld)", iter->func, iter->line);
 			if (rpc->struct_add(stats_th, "d", buff, iter->size) < 0) {
 				rpc->fault(ctx, 500, "Internal error adding to struct rpc");
 				return -1;




More information about the sr-dev mailing list