[Asterisk-cvs] asterisk asterisk.c,1.21,1.22 cdr.c,1.5,1.6

martinp at lists.digium.com martinp at lists.digium.com
Tue Sep 16 23:20:48 CDT 2003


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

Modified Files:
	asterisk.c cdr.c 
Log Message:
Don't complain that wait4 is unkown and make sure that we won't segfault if chan->cdr is NULL


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- asterisk.c	16 Sep 2003 19:35:56 -0000	1.21
+++ asterisk.c	17 Sep 2003 04:21:56 -0000	1.22
@@ -38,6 +38,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/select.h>
+#include <sys/wait.h>
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>

Index: cdr.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cdr.c	12 Sep 2003 16:51:35 -0000	1.5
+++ cdr.c	17 Sep 2003 04:21:56 -0000	1.6
@@ -351,30 +351,28 @@
 	char *name, *num;
 	char tmp[AST_MAX_EXTENSION] = "";
 	/* Grab source from ANI or normal Caller*ID */
-	if (!cdr) {
-		ast_log(LOG_NOTICE, "The cdr pointer is not set\n");
-		return -1;
-	}
-	if (c->ani)
-		strncpy(tmp, c->ani, sizeof(tmp) - 1);
-	else if (c->callerid && strlen(c->callerid))
-		strncpy(tmp, c->callerid, sizeof(tmp) - 1);
-	if (c->callerid && strlen(c->callerid))
-		strncpy(cdr->clid, c->callerid, sizeof(cdr->clid) - 1);
-	else
-		strcpy(cdr->clid, "");
-	name = NULL;
-	num = NULL;
-	ast_callerid_parse(tmp, &name, &num);
-	if (num) {
-		ast_shrink_phone_number(num);
-		strncpy(cdr->src, num, sizeof(cdr->src) - 1);
+	if (cdr) {
+		if (c->ani)
+			strncpy(tmp, c->ani, sizeof(tmp) - 1);
+		else if (c->callerid && strlen(c->callerid))
+			strncpy(tmp, c->callerid, sizeof(tmp) - 1);
+		if (c->callerid && strlen(c->callerid))
+			strncpy(cdr->clid, c->callerid, sizeof(cdr->clid) - 1);
+		else
+			strcpy(cdr->clid, "");
+		name = NULL;
+		num = NULL;
+		ast_callerid_parse(tmp, &name, &num);
+		if (num) {
+			ast_shrink_phone_number(num);
+			strncpy(cdr->src, num, sizeof(cdr->src) - 1);
+		}
+		/* Copy account code et-al */	
+		strncpy(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode) - 1);
+		/* Destination information */
+		strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1);
+		strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1);
 	}
-	/* Copy account code et-al */	
-	strncpy(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode) - 1);
-	/* Destination information */
-	strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1);
-	strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1);
 	return 0;
 }
 
@@ -421,18 +419,20 @@
 
 void ast_cdr_reset(struct ast_cdr *cdr, int post)
 {
-	/* Post if requested */
-	if (post) {
-		ast_cdr_end(cdr);
-		ast_cdr_post(cdr);
+	if (cdr) {
+		/* Post if requested */
+		if (post) {
+			ast_cdr_end(cdr);
+			ast_cdr_post(cdr);
+		}
+		/* Reset to initial state */
+		cdr->posted = 0;
+		memset(&cdr->start, 0, sizeof(cdr->start));
+		memset(&cdr->end, 0, sizeof(cdr->end));
+		memset(&cdr->answer, 0, sizeof(cdr->answer));
+		cdr->billsec = 0;
+		cdr->duration = 0;
+		ast_cdr_start(cdr);
+		cdr->disposition = AST_CDR_NOANSWER;
 	}
-	/* Reset to initial state */
-	cdr->posted = 0;
-	memset(&cdr->start, 0, sizeof(cdr->start));
-	memset(&cdr->end, 0, sizeof(cdr->end));
-	memset(&cdr->answer, 0, sizeof(cdr->answer));
-	cdr->billsec = 0;
-	cdr->duration = 0;
-	ast_cdr_start(cdr);
-	cdr->disposition = AST_CDR_NOANSWER;
 }




More information about the svn-commits mailing list