diff options
author | 2010-01-27 19:42:24 +0000 | |
---|---|---|
committer | 2010-01-27 19:42:24 +0000 | |
commit | 4526f4da65bc00d61d242a1af959529ea4555caa (patch) | |
tree | c40d293bccd3e8fcd349b4499fb192521198620a | |
parent | d1ec4a57bab7eb2cb1cb44b9e8951c7fead025df (diff) |
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
-rw-r--r-- | gui/skin/font.c | 4 | ||||
-rw-r--r-- | 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] == ';' ) { |