[MPlayer-cvslog] r31626 - trunk/mp_msg.c

reimar subversion at mplayerhq.hu
Sat Jul 3 01:43:10 CEST 2010


Author: reimar
Date: Sat Jul  3 01:43:09 2010
New Revision: 31626

Log:
Avoid out-of-bounds read if mp_msg prints an empty string.

Modified:
   trunk/mp_msg.c

Modified: trunk/mp_msg.c
==============================================================================
--- trunk/mp_msg.c	Fri Jul  2 23:19:21 2010	(r31625)
+++ trunk/mp_msg.c	Sat Jul  3 01:43:09 2010	(r31626)
@@ -181,6 +181,7 @@ void mp_msg(int mod, int lev, const char
     char tmp[MSGSIZE_MAX];
     FILE *stream = lev <= MSGL_WARN ? stderr : stdout;
     static int header = 1;
+    size_t len;
 
     if (!mp_msg_test(mod, lev)) return; // do not display
     va_start(va, format);
@@ -223,7 +224,8 @@ void mp_msg(int mod, int lev, const char
     if (header)
         print_msg_module(stream, mod);
     set_msg_color(stream, lev);
-    header = tmp[strlen(tmp)-1] == '\n' || tmp[strlen(tmp)-1] == '\r';
+    len = strlen(tmp);
+    header = len && (tmp[len-1] == '\n' || tmp[len-1] == '\r');
 
     fprintf(stream, "%s", tmp);
     if (mp_msg_color)


More information about the MPlayer-cvslog mailing list