[Asterisk-cvs] asterisk/channels chan_zap.c,1.361,1.362

citats at lists.digium.com citats at lists.digium.com
Sat Oct 23 16:29:17 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv2675/channels

Modified Files:
	chan_zap.c 
Log Message:
Check return value of malloc before dereferencing ptr in chan_zap.c

Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.361
retrieving revision 1.362
diff -u -d -r1.361 -r1.362
--- chan_zap.c	23 Oct 2004 12:19:47 -0000	1.361
+++ chan_zap.c	23 Oct 2004 20:33:01 -0000	1.362
@@ -3495,15 +3495,19 @@
 									if (p->zaptrcallerid) {
 										if (!p->origcid_num) {
 											p->origcid_num = malloc(strlen(p->cid_num) + 1);
-											strncpy(p->origcid_num, p->cid_num, strlen(p->cid_num)); /* safe */
-											/* make sure p->origcallerid is terminated */
-											p->origcid_num[strlen(p->cid_num)] = '\0';
+											if (p->origcid_num) {
+												strncpy(p->origcid_num, p->cid_num, strlen(p->cid_num)); /* safe */
+												/* make sure p->origcallerid is terminated */
+												p->origcid_num[strlen(p->cid_num)] = '\0';
+											}
 										}
 										if (!p->origcid_name) {
 											p->origcid_name = malloc(strlen(p->cid_name) + 1);
-											strncpy(p->origcid_name, p->cid_name, strlen(p->cid_name)); /* safe */
-											/* make sure p->origcallerid is terminated */
-											p->origcid_name[strlen(p->cid_name)] = '\0';
+											if (p->origcid_name) {
+												strncpy(p->origcid_name, p->cid_name, strlen(p->cid_name)); /* safe */
+												/* make sure p->origcallerid is terminated */
+												p->origcid_name[strlen(p->cid_name)] = '\0';
+											}
 										}
 										strncpy(p->cid_num, cid_num, sizeof(p->cid_num) -1);
 										strncpy(p->cid_name, cid_name, sizeof(p->cid_name) -1);




More information about the svn-commits mailing list