[block_vvfat.c] slightly increase buffer size to avoid array-bounds and stringop-overflow= errors

This commit is contained in:
Gwenhael Le Moine 2024-10-22 21:53:59 +02:00
parent 25a78e1ccc
commit 00f57c458f
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 9 additions and 8 deletions

View file

@ -95,9 +95,7 @@ X49GP_CFLAGS = -O2 \
$(DEBUG) \ $(DEBUG) \
$(INCLUDES) \ $(INCLUDES) \
$(DEFINES) \ $(DEFINES) \
-Wno-error=deprecated-declarations \ -Wno-error=deprecated-declarations
-Wno-error=stringop-overflow= \
-Wno-error=array-bounds
X49GP_LDFLAGS += $(DEBUG) $(GDB_LDFLAGS) X49GP_LDFLAGS += $(DEBUG) $(GDB_LDFLAGS)
X49GP_LDLIBS = $(X49GP_LIBS) $(GDB_LIBS) $(COCOA_LIBS) X49GP_LDLIBS = $(X49GP_LIBS) $(GDB_LIBS) $(COCOA_LIBS)

View file

@ -437,24 +437,27 @@ static inline int short2long_name( char* dest, const char* src )
dest[ 2 * i ] = dest[ 2 * i + 1 ] = 0; dest[ 2 * i ] = dest[ 2 * i + 1 ] = 0;
for ( i = 2 * i + 2; ( i % 26 ); i++ ) for ( i = 2 * i + 2; ( i % 26 ); i++ )
dest[ i ] = 0xff; dest[ i ] = 0xff;
return i; return i;
} }
static inline direntry_t* create_long_filename( BDRVVVFATState* s, const char* filename ) static inline direntry_t* create_long_filename( BDRVVVFATState* s, const char* filename )
{ {
char buffer[ 258 ]; char buffer[ 260 ];
int length = short2long_name( buffer, filename ), number_of_entries = ( length + 25 ) / 26, i; int length = short2long_name( buffer, filename );
int number_of_entries = ( length + 25 ) / 26;
int offset;
direntry_t* entry; 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 = array_get_next( &( s->directory ) );
entry->attributes = 0xf; entry->attributes = 0xf;
entry->reserved[ 0 ] = 0; entry->reserved[ 0 ] = 0;
entry->begin = 0; entry->begin = 0;
entry->name[ 0 ] = ( number_of_entries - i ) | ( i == 0 ? 0x40 : 0 ); entry->name[ 0 ] = ( number_of_entries - i ) | ( i == 0 ? 0x40 : 0 );
} }
for ( i = 0; i < length; i++ ) { for ( int i = 0; i < length; i++ ) {
int offset = ( i % 26 ); offset = ( i % 26 );
if ( offset < 10 ) if ( offset < 10 )
offset = 1 + offset; offset = 1 + offset;
else if ( offset < 22 ) else if ( offset < 22 )