diff --git a/public/crtlib.c b/public/crtlib.c index d73b0113..cb066df0 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -645,14 +645,14 @@ void COM_ReplaceExtension( char *path, const char *extension, size_t size ) COM_RemoveLineFeed ============ */ -void COM_RemoveLineFeed( char *str ) +void COM_RemoveLineFeed( char *str, size_t bufsize ) { - while( *str != '\0' ) + size_t i; + + for( i = 0; i < bufsize && *str != '\0'; i++, str++ ) { if( *str == '\r' || *str == '\n' ) *str = '\0'; - - ++str; } } diff --git a/public/crtlib.h b/public/crtlib.h index ee3e8d19..ad9d345c 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -86,7 +86,7 @@ void COM_ReplaceExtension( char *path, const char *extension, size_t size ); void COM_ExtractFilePath( const char *path, char *dest ); const char *COM_FileWithoutPath( const char *in ); void COM_StripExtension( char *path ); -void COM_RemoveLineFeed( char *str ); +void COM_RemoveLineFeed( char *str, size_t bufsize ); void COM_FixSlashes( char *pname ); void COM_PathSlashFix( char *path ); char COM_Hex2Char( uint8_t hex ); diff --git a/utils/mdldec/qc.c b/utils/mdldec/qc.c index 78fbdfd9..a5bc4476 100644 --- a/utils/mdldec/qc.c +++ b/utils/mdldec/qc.c @@ -79,7 +79,7 @@ qboolean LoadActivityList( const char *appname ) return false; } - COM_RemoveLineFeed( buf ); + COM_RemoveLineFeed( buf, sizeof( buf )); activity_names[activity_count - 1] = strdup( buf );