Browse Source

Corrected warnings

master
Christopher Snowhill 6 years ago
parent
commit
8211cfff5f
2 changed files with 30 additions and 11 deletions
  1. +7
    -3
      psf2fs.c
  2. +23
    -8
      psflib.c

+ 7
- 3
psf2fs.c View File

@@ -105,7 +105,11 @@ static void makelibpath(const char *path, const char *libpath, char *finalpath,
finalpath_length -= p_l;
}
if(!finalpath_length) return;
#if _MSC_VER >= 1300
strcpy_s(finalpath, finalpath_length, libpath);
#else
strncpy(finalpath, libpath, finalpath_length);
#endif
finalpath[finalpath_length - 1] = 0;
}

@@ -221,7 +225,7 @@ static struct DIR_ENTRY *makearchivedir(
dir->offset_table[i] = dataofs;
}
}
success:
//success:
return dir;

corrupt:
@@ -336,7 +340,7 @@ static int addarchive(
// now merge everything
*psource = mergesource(source, this_source);
*pdir = mergedir(dir, this_dir);
success:
//success:
return 0;

outofmemory:
@@ -430,7 +434,7 @@ static int virtual_read(struct PSF2FS *fs, struct DIR_ENTRY *entry, int offset,
buffer += canread;
}

success:
//success:
return length_read;

bounds:


+ 23
- 8
psflib.c View File

@@ -189,11 +189,16 @@ static psf_tag * add_tag_multi( psf_tag * tags, const char * name, const char **
if ( tag->value )
{
size_t old_length = strlen(tag->value);
char * new_value = (char *) realloc( tag->value, old_length + strlen( values[ 0 ] ) + 2 );
size_t new_length = strlen( values[ 0 ] );
char * new_value = (char *) realloc( tag->value, old_length + new_length + 2 );
if (!new_value) return footer;
tag->value = new_value;
new_value[ old_length ] = '\n';
#if _MSC_VER >= 1300
strcpy_s( new_value + old_length + 1, new_length + 1, values[ 0 ] );
#else
strcpy( new_value + old_length + 1, values[ 0 ] );
#endif
}
else
{
@@ -247,10 +252,10 @@ static psf_tag * add_tag( psf_tag * tags, const char * name, const char * value
while ( split_point )
{
values_count++;
new_values = realloc( values, sizeof(const char*) * ((values_count + 3) & ~3) );
new_values = (const char **) realloc( (void *) values, sizeof(const char*) * ((values_count + 3) & ~3) );
if ( !new_values )
{
if ( values ) free( values );
if ( values ) free( (void *) values );
free( value_split );
return tags;
}
@@ -263,10 +268,10 @@ static psf_tag * add_tag( psf_tag * tags, const char * name, const char * value
if ( *remain )
{
values_count++;
new_values = realloc( values, sizeof(char*) * ((values_count + 3) & ~3) );
new_values = (const char **) realloc( (void *) values, sizeof(char*) * ((values_count + 3) & ~3) );
if ( !new_values )
{
if ( values ) free( values );
if ( values ) free( (void *) values );
free( value_split );
return tags;
}
@@ -286,7 +291,7 @@ static psf_tag * add_tag( psf_tag * tags, const char * name, const char * value
tags = add_tag_multi( tags, name, values, values_count );

if ( value_split ) free( value_split );
free( values );
free( (void *) values );

return tags;
}
@@ -371,13 +376,21 @@ static int psf_load_internal( psf_load_state * state, const char * file_name )

int zerr;

size_t full_path_size;

if ( ++state->depth > max_recursion_depth ) return -1;

full_path = (char *) malloc( strlen(state->base_path) + strlen(file_name) + 1 );
full_path_size = strlen(state->base_path) + strlen(file_name) + 1;
full_path = (char *) malloc( full_path_size );
if ( !full_path ) return -1;

#if _MSC_VER >= 1300
strcpy_s( full_path, full_path_size, state->base_path );
strcat_s( full_path, full_path_size, file_name );
#else
strcpy( full_path, state->base_path );
strcat( full_path, file_name );
#endif

file = state->file_callbacks->fopen( full_path );

@@ -399,7 +412,9 @@ static int psf_load_internal( psf_load_state * state, const char * file_name )

file_size = state->file_callbacks->ftell( file );

if ( file_size >= 16 + reserved_size + exe_compressed_size + 5 )
if ( file_size <= 0 ) goto error_close_file;

if ( (unsigned long)file_size >= 16 + reserved_size + exe_compressed_size + 5 )
{
tag_size = file_size - ( 16 + reserved_size + exe_compressed_size );
if ( state->file_callbacks->fseek( file, -tag_size, SEEK_CUR ) ) goto error_close_file;


Loading…
Cancel
Save