From 00f57c458f7a1fd1cd279394b0cba29152e3a8ab Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Tue, 22 Oct 2024 21:53:59 +0200 Subject: [PATCH] [block_vvfat.c] slightly increase buffer size to avoid array-bounds and stringop-overflow= errors --- Makefile | 4 +--- src/block-vvfat.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index fc21db3..5a50226 100644 --- a/Makefile +++ b/Makefile @@ -95,9 +95,7 @@ X49GP_CFLAGS = -O2 \ $(DEBUG) \ $(INCLUDES) \ $(DEFINES) \ - -Wno-error=deprecated-declarations \ - -Wno-error=stringop-overflow= \ - -Wno-error=array-bounds + -Wno-error=deprecated-declarations X49GP_LDFLAGS += $(DEBUG) $(GDB_LDFLAGS) X49GP_LDLIBS = $(X49GP_LIBS) $(GDB_LIBS) $(COCOA_LIBS) diff --git a/src/block-vvfat.c b/src/block-vvfat.c index 4d48d24..f317684 100644 --- a/src/block-vvfat.c +++ b/src/block-vvfat.c @@ -437,24 +437,27 @@ static inline int short2long_name( char* dest, const char* src ) dest[ 2 * i ] = dest[ 2 * i + 1 ] = 0; for ( i = 2 * i + 2; ( i % 26 ); i++ ) dest[ i ] = 0xff; + return i; } static inline direntry_t* create_long_filename( BDRVVVFATState* s, const char* filename ) { - char buffer[ 258 ]; - int length = short2long_name( buffer, filename ), number_of_entries = ( length + 25 ) / 26, i; + char buffer[ 260 ]; + int length = short2long_name( buffer, filename ); + int number_of_entries = ( length + 25 ) / 26; + int offset; direntry_t* entry; - for ( i = 0; i < number_of_entries; i++ ) { + for ( int i = 0; i < number_of_entries; i++ ) { entry = array_get_next( &( s->directory ) ); entry->attributes = 0xf; entry->reserved[ 0 ] = 0; entry->begin = 0; entry->name[ 0 ] = ( number_of_entries - i ) | ( i == 0 ? 0x40 : 0 ); } - for ( i = 0; i < length; i++ ) { - int offset = ( i % 26 ); + for ( int i = 0; i < length; i++ ) { + offset = ( i % 26 ); if ( offset < 10 ) offset = 1 + offset; else if ( offset < 22 )