[Asterisk-cvs] asterisk/formats format_g729.c,1.9,1.10 format_gsm.c,1.14,1.15 format_pcm.c,1.10,1.11 format_pcm_alaw.c,1.9,1.10 format_wav.c,1.15,1.16 format_wav_gsm.c,1.18,1.19

markster at lists.digium.com markster at lists.digium.com
Thu Apr 15 11:59:55 CDT 2004


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

Modified Files:
	format_g729.c format_gsm.c format_pcm.c format_pcm_alaw.c 
	format_wav.c format_wav_gsm.c 
Log Message:
Do proper bounds checking in formats (bug #1356)


Index: format_g729.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_g729.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- format_g729.c	28 Jan 2004 21:32:48 -0000	1.9
+++ format_g729.c	15 Apr 2004 16:02:42 -0000	1.10
@@ -183,8 +183,9 @@
 		offset = max - bytes;
 	if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
-		offset = (offset < min)?min:offset;
 	}
+	// protect against seeking beyond begining.
+	offset = (offset < min)?min:offset;
 	if (lseek(fs->fd, offset, SEEK_SET) < 0)
 		return -1;
 	return 0;

Index: format_gsm.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_gsm.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- format_gsm.c	3 Feb 2004 16:57:00 -0000	1.14
+++ format_gsm.c	15 Apr 2004 16:02:42 -0000	1.15
@@ -197,9 +197,10 @@
 		offset = distance + cur;
 	else if(whence == SEEK_END)
 		offset = max - distance;
+	// Always protect against seeking past the begining.
+	offset = (offset < min)?min:offset;
 	if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
-		offset = (offset < min)?min:offset;
 	} else if (offset > max) {
 		int i;
 		lseek(fs->fd, 0, SEEK_END);

Index: format_pcm.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_pcm.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- format_pcm.c	8 Sep 2003 16:48:07 -0000	1.10
+++ format_pcm.c	15 Apr 2004 16:02:42 -0000	1.11
@@ -172,8 +172,9 @@
 		offset = max - sample_offset;
 	if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
-		offset = (offset < min)?min:offset;
 	}
+	// always protect against seeking past begining.
+	offset = (offset < min)?min:offset;
 	return lseek(fs->fd, offset, SEEK_SET);
 }
 

Index: format_pcm_alaw.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_pcm_alaw.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- format_pcm_alaw.c	28 Jan 2004 21:06:03 -0000	1.9
+++ format_pcm_alaw.c	15 Apr 2004 16:02:42 -0000	1.10
@@ -253,8 +253,9 @@
 		offset = max - sample_offset;
 	if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
-		offset = (offset < min)?min:offset;
 	}
+	// Always protect against seeking past begining
+	offset = (offset < min)?min:offset;
 	return lseek(fs->fd, offset, SEEK_SET);
 }
 

Index: format_wav.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_wav.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- format_wav.c	2 Feb 2004 06:34:27 -0000	1.15
+++ format_wav.c	15 Apr 2004 16:02:42 -0000	1.16
@@ -525,8 +525,9 @@
 		offset = max - samples;
         if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
-		offset = (offset < min)?min:offset;
 	}
+	// always protect the header space.
+	offset = (offset < min)?min:offset;
 	return lseek(fs->fd,offset,SEEK_SET);
 }
 

Index: format_wav_gsm.c
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/format_wav_gsm.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- format_wav_gsm.c	26 Feb 2004 06:46:01 -0000	1.18
+++ format_wav_gsm.c	15 Apr 2004 16:02:42 -0000	1.19
@@ -493,8 +493,9 @@
 		offset = distance + cur;
 	else if(whence == SEEK_END)
 		offset = max - distance;
+	// always protect against seeking past end of header
+	offset = (offset < min)?min:offset;
 	if (whence != SEEK_FORCECUR) {
-		offset = (offset < min)?min:offset;
 		offset = (offset > max)?max:offset;
 	} else if (offset > max) {
 		int i;




More information about the svn-commits mailing list