[asterisk-commits] russell: branch 1.2-netsec r75462 - in /branches/1.2-netsec: ./ channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 17 16:09:39 CDT 2007


Author: russell
Date: Tue Jul 17 16:09:39 2007
New Revision: 75462

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75462
Log:
get branch up to date to include ASA fixes

Modified:
    branches/1.2-netsec/   (props changed)
    branches/1.2-netsec/channels/chan_iax2.c
    branches/1.2-netsec/channels/chan_skinny.c
    branches/1.2-netsec/channels/iax2-parser.c
    branches/1.2-netsec/channels/iax2-parser.h

Propchange: branches/1.2-netsec/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jul 17 16:09:39 2007
@@ -1,1 +1,1 @@
-/branches/1.2:1-75349
+/branches/1.2:1-75461

Modified: branches/1.2-netsec/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2-netsec/channels/chan_iax2.c?view=diff&rev=75462&r1=75461&r2=75462
==============================================================================
--- branches/1.2-netsec/channels/chan_iax2.c (original)
+++ branches/1.2-netsec/channels/chan_iax2.c Tue Jul 17 16:09:39 2007
@@ -4020,7 +4020,9 @@
 	int sendmini=0;
 	unsigned int lastsent;
 	unsigned int fts;
-		
+
+	frb.fr2.afdatalen = sizeof(frb.buffer);
+
 	if (!pvt) {
 		ast_log(LOG_WARNING, "No private structure for packet?\n");
 		return -1;
@@ -6435,7 +6437,8 @@
 	/* allocate an iax_frame with 4096 bytes of data buffer */
 	fr = alloca(sizeof(*fr) + 4096);
 	fr->callno = 0;
-	
+	fr->afdatalen = 4096; /* From alloca() above */
+
 	res = recvfrom(fd, buf, sizeof(buf), 0,(struct sockaddr *) &sin, &len);
 	if (res < 0) {
 		if (errno != ECONNREFUSED)
@@ -6811,6 +6814,7 @@
 					return 1;
 				}
 				f.data = NULL;
+				f.datalen = 0;
 			} else
 				f.data = buf + sizeof(*fh);
 		} else {

Modified: branches/1.2-netsec/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/branches/1.2-netsec/channels/chan_skinny.c?view=diff&rev=75462&r1=75461&r2=75462
==============================================================================
--- branches/1.2-netsec/channels/chan_skinny.c (original)
+++ branches/1.2-netsec/channels/chan_skinny.c Tue Jul 17 16:09:39 2007
@@ -2862,7 +2862,7 @@
 			return -1;
 		}
 		dlen = letohl(*(int *)s->inbuf);
-		if (dlen < 0) {
+		if (dlen < 4) {
 			ast_log(LOG_WARNING, "Skinny Client sent invalid data.\n");
 			return -1;
 		}

Modified: branches/1.2-netsec/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/branches/1.2-netsec/channels/iax2-parser.c?view=diff&rev=75462&r1=75461&r2=75462
==============================================================================
--- branches/1.2-netsec/channels/iax2-parser.c (original)
+++ branches/1.2-netsec/channels/iax2-parser.c Tue Jul 17 16:09:39 2007
@@ -904,13 +904,20 @@
 	fr->af.delivery.tv_usec = 0;
 	fr->af.data = fr->afdata;
 	if (fr->af.datalen) {
+		size_t copy_len = fr->af.datalen;
+		if (copy_len > fr->afdatalen) {
+			ast_log(LOG_ERROR, "Losing frame data because destination buffer size '%d' bytes not big enough for '%d' bytes in the frame\n",
+				(int) fr->afdatalen, (int) fr->af.datalen);
+			copy_len = fr->afdatalen;
+		}
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 		/* We need to byte-swap slinear samples from network byte order */
 		if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) {
-			ast_swapcopy_samples(fr->af.data, f->data, fr->af.samples);
+			/* 2 bytes / sample for SLINEAR */
+			ast_swapcopy_samples(fr->af.data, f->data, copy_len / 2);
 		} else
 #endif
-		memcpy(fr->af.data, f->data, fr->af.datalen);
+			memcpy(fr->af.data, f->data, copy_len);
 	}
 }
 
@@ -919,6 +926,7 @@
 	struct iax_frame *fr;
 	fr = malloc((int)sizeof(struct iax_frame) + datalen);
 	if (fr) {
+		fr->afdatalen = datalen;
 		fr->direction = direction;
 		fr->retrans = -1;
 		frames++;

Modified: branches/1.2-netsec/channels/iax2-parser.h
URL: http://svn.digium.com/view/asterisk/branches/1.2-netsec/channels/iax2-parser.h?view=diff&rev=75462&r1=75461&r2=75462
==============================================================================
--- branches/1.2-netsec/channels/iax2-parser.h (original)
+++ branches/1.2-netsec/channels/iax2-parser.h Tue Jul 17 16:09:39 2007
@@ -119,6 +119,8 @@
 	struct iax_frame *prev;
 	/* Actual, isolated frame header */
 	struct ast_frame af;
+	/* Amount of data _allocated_ for afdata */
+	size_t afdatalen;
 	unsigned char unused[AST_FRIENDLY_OFFSET];
 	unsigned char afdata[0];	/* Data for frame */
 };




More information about the asterisk-commits mailing list