From ed5cefb1173fab4b6c94cac307b68d368c169c81 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Mon, 6 Jun 2011 16:33:10 +0200 Subject: [PATCH] For all filename strings use PATH_MAX as size, make sure they are inited correctly and only fill them with snprintf instead of sprintf --- CHANGELOG.txt | 4 ++++ main/playsave.c | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 87c2578e4..b95f136c6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20110606 +-------- +main/playsave.c: For all filename strings use PATH_MAX as size, make sure they are inited correctly and only fill them with snprintf instead of sprintf + 20110604 -------- main/lighting.c: Since set_dynamic_light() is not necessarily processed each frame, added own counter for delayed precession of vertex-clight calculation; Added possibility to page in a bitmap in case an object which has never been rendered before is supposed to cast light visible by the player diff --git a/main/playsave.c b/main/playsave.c index 4e78eda36..d6e218f49 100644 --- a/main/playsave.c +++ b/main/playsave.c @@ -113,7 +113,7 @@ int read_player_d1x(char *filename) { PHYSFS_file *f; int rc = 0; - char line[60],*word; + char line[50],*word; int Stop=0; plyr_read_stats(); @@ -404,8 +404,9 @@ void plyr_read_stats_v(int *k, int *d){ PHYSFS_file *f; *k=0;*d=0;//in case the file doesn't exist. - - sprintf(filename,GameArg.SysUsePlayersDir?"Players/%s.eff":"%s.eff",Players[Player_num].callsign); + + memset(filename, '\0', PATH_MAX); + snprintf(filename,PATH_MAX,GameArg.SysUsePlayersDir?"Players/%s.eff":"%s.eff",Players[Player_num].callsign); f = PHYSFSX_openReadBuffered(filename); if(f) @@ -633,14 +634,15 @@ int write_player_d1x(char *filename) //read in the player's saved games. returns errno (0 == no error) int read_player_file() { - char filename[32]; + char filename[PATH_MAX]; PHYSFS_file *file; int player_file_size, shareware_file = -1, id = 0; short saved_game_version, player_struct_version; Assert(Player_num>=0 && Player_num