[MPlayer-cvslog] r30446 - in trunk/gui/skin: font.c skin.c
reimar
subversion at mplayerhq.hu
Wed Jan 27 20:42:24 CET 2010
Author: reimar
Date: Wed Jan 27 20:42:24 2010
New Revision: 30446
Log:
Fix newline removal code that might read and write out of bounds.
Modified:
trunk/gui/skin/font.c
trunk/gui/skin/skin.c
Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c Wed Jan 27 20:15:49 2010 (r30445)
+++ trunk/gui/skin/font.c Wed Jan 27 20:42:24 2010 (r30446)
@@ -87,8 +87,8 @@ int fntRead( char * path,char * fname )
{
fgets( tmp,255,f ); linenumber++;
- c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
- c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
+ // remove any kind of newline, if any
+ tmp[strcspn(tmp, "\n\r")] = 0;
for ( c=0;c < (int)strlen( tmp );c++ )
if ( tmp[c] == ';' ) { tmp[c]=0; break; }
if ( !tmp[0] ) continue;
Modified: trunk/gui/skin/skin.c
==============================================================================
--- trunk/gui/skin/skin.c Wed Jan 27 20:15:49 2010 (r30445)
+++ trunk/gui/skin/skin.c Wed Jan 27 20:42:24 2010 (r30446)
@@ -717,8 +717,8 @@ int skinRead( char * dname )
{
linenumber++;
- c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
- c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0;
+ // remove any kind of newline, if any
+ tmp[strcspn(tmp, "\n\r")] = 0;
for ( c=0;c<(int)strlen( tmp );c++ )
if ( tmp[c] == ';' )
{
More information about the MPlayer-cvslog
mailing list