From 4526f4da65bc00d61d242a1af959529ea4555caa Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 27 Jan 2010 19:42:24 +0000 Subject: [PATCH] Fix newline removal code that might read and write out of bounds. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30446 b3059339-0415-0410-9bf9-f77b7e298cf2 --- gui/skin/font.c | 4 ++-- gui/skin/skin.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/skin/font.c b/gui/skin/font.c index f565289925..e3f1bee5cc 100644 --- a/gui/skin/font.c +++ b/gui/skin/font.c @@ -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; diff --git a/gui/skin/skin.c b/gui/skin/skin.c index 50d31b74d7..fc0a5e40ab 100644 --- a/gui/skin/skin.c +++ b/gui/skin/skin.c @@ -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] == ';' ) {