[MPlayer-dev-eng] [PATCH] stupid pragma-len check in asf_streaming.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Mar 8 13:51:48 CET 2006


Hi,
attached is a proposal for fixing $subject. Problem 1: features[len] can
be outside the array, since someone forgot the needed space for the
terminating 0.
Problem 2: The ParseWarnCuttedPragma message is only printed in the
(end == NULL) case, not when it is truncated in the else path.
This seemed like the best solution to me, though maybe not the one with
the smallest diff.
Please comment.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: asf_streaming.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/asf_streaming.c,v
retrieving revision 1.60
diff -u -r1.60 asf_streaming.c
--- asf_streaming.c	6 Nov 2005 15:25:08 -0000	1.60
+++ asf_streaming.c	8 Mar 2006 12:46:46 -0000
@@ -680,15 +680,13 @@
 				pragma += 9;
 				end = strstr( pragma, "," );
 				if( end==NULL ) {
-				  size_t s = strlen(pragma);
-				  if(s > sizeof(features)) {
-				    mp_msg(MSGT_NETWORK,MSGL_WARN,MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma,pragma,s,sizeof(features));
-				    len = sizeof(features);
-				  } else {				   
-				    len = s;
-				  }
+				  len = strlen(pragma);
 				} else { 
-				  len = MIN((unsigned int)(end-pragma),sizeof(features));
+				  len = (unsigned int)(end-pragma);
+				}
+				if(len > sizeof(features) - 1) {
+				  mp_msg(MSGT_NETWORK,MSGL_WARN,MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma,pragma,s,sizeof(features));
+				  len = sizeof(features) - 1;
 				}
 				strncpy( features, pragma, len );
 				features[len]='\0';


More information about the MPlayer-dev-eng mailing list