[sr-dev] git:master:72d56337: core: use snprintf() instead of sprintf() in hash testing function

Daniel-Constantin Mierla miconda at gmail.com
Fri Nov 15 18:34:33 CET 2019


Module: kamailio
Branch: master
Commit: 72d56337b49b1bfdeb74773edc9a973cfcdefe70
URL: https://github.com/kamailio/kamailio/commit/72d56337b49b1bfdeb74773edc9a973cfcdefe70

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-11-15T18:33:38+01:00

core: use snprintf() instead of sprintf() in hash testing function

---

Modified: src/core/hash_func.c

---

Diff:  https://github.com/kamailio/kamailio/commit/72d56337b49b1bfdeb74773edc9a973cfcdefe70.diff
Patch: https://github.com/kamailio/kamailio/commit/72d56337b49b1bfdeb74773edc9a973cfcdefe70.patch

---

diff --git a/src/core/hash_func.c b/src/core/hash_func.c
index 71d12f0d25..67b2934e33 100644
--- a/src/core/hash_func.c
+++ b/src/core/hash_func.c
@@ -125,7 +125,7 @@ void hashtest_cycle( int hits[TABLE_ENTRIES+5], char *ip )
 	int  hashv;
 	static char buf1[1024];
 	static char buf2[1024];
-	str call_id; 
+	str call_id;
 	str cseq;
 
 	call_id.s=buf1;
@@ -135,11 +135,11 @@ void hashtest_cycle( int hits[TABLE_ENTRIES+5], char *ip )
 		for (j=85296341;j<85296341+10;j++)
 			for (k=987654;k<=987654+10;k++)
 				for (l=101;l<201;l++) {
-					call_id.len=sprintf( buf1, "%d-%d-%d@%s",(int)i,(int)j,
-						(int)k, ip );
-					cseq.len=sprintf( buf2, "%d", (int)l );
+					call_id.len=snprintf(buf1, 1024, "%d-%d-%d@%s",(int)i,(int)j,
+						(int)k, ip);
+					cseq.len=snprintf(buf2, 1024, "%d", (int)l );
 					/* printf("%s\t%s\n", buf1, buf2 ); */
-					hashv=hash( call_id, cseq );
+					hashv=hash(call_id, cseq);
 					hits[ hashv ]++;
 				}
 }




More information about the sr-dev mailing list