[MPlayer-cvslog] r29636 - trunk/mplayer.c

reimar subversion at mplayerhq.hu
Wed Sep 2 21:49:10 CEST 2009


Author: reimar
Date: Wed Sep  2 21:49:10 2009
New Revision: 29636

Log:
Limit amount of data allocated on stack, strlen(filename) is not a good idea for
file name strings that might come from arbitrary playlists, use PATH_MAX instead.

Modified:
   trunk/mplayer.c

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Wed Sep  2 21:44:15 2009	(r29635)
+++ trunk/mplayer.c	Wed Sep  2 21:49:10 2009	(r29636)
@@ -931,9 +931,13 @@ static int try_load_config(m_config_t *c
 static void load_per_file_config (m_config_t* conf, const char *const file)
 {
     char *confpath;
-    char cfg[strlen(file)+10];
+    char cfg[PATH_MAX];
     char *name;
 
+    if (strlen(file) > PATH_MAX - 14) {
+        mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, can not load file or directory specific config files\n");
+        return;
+    }
     sprintf (cfg, "%s.conf", file);
 
     name = strrchr(cfg, '/');
@@ -951,7 +955,7 @@ static void load_per_file_config (m_conf
 	name++;
 
     if (use_filedir_conf) {
-        char dircfg[strlen(file)+14];
+        char dircfg[PATH_MAX];
         strcpy(dircfg, cfg);
         strcpy(dircfg + (name - cfg), "mplayer.conf");
         try_load_config(conf, dircfg);


More information about the MPlayer-cvslog mailing list