Remove PHYSFSX_gets, PHYSFSX_readString

They do not check for a buffer overflow.
This commit is contained in:
Kp 2012-07-15 18:51:47 +00:00
parent 4e7e3fa0c8
commit 3bf16e57dc
3 changed files with 4 additions and 32 deletions

View file

@ -65,34 +65,6 @@ static inline void PHYSFSX_readAngleVecX(PHYSFS_file *file, vms_angvec *v, int s
v->h = PHYSFSX_readSXE16(file, swap);
}
static inline int PHYSFSX_readString(PHYSFS_file *file, char *s)
{
char *ptr = s;
if (PHYSFS_eof(file))
*ptr = 0;
else
do
PHYSFS_read(file, ptr, 1, 1);
while (!PHYSFS_eof(file) && *ptr++ != 0);
return strlen(s);
}
static inline int PHYSFSX_gets(PHYSFS_file *file, char *s)
{
char *ptr = s;
if (PHYSFS_eof(file))
*ptr = 0;
else
do
PHYSFS_read(file, ptr, 1, 1);
while (!PHYSFS_eof(file) && *ptr++ != '\n');
return strlen(s);
}
static inline int PHYSFSX_writeU8(PHYSFS_file *file, PHYSFS_uint8 val)
{
return PHYSFS_write(file, &val, 1, 1);

View file

@ -139,7 +139,7 @@ int ReadConfigFile()
int max_len = PHYSFS_fileLength(infile); // to be fully safe, assume the whole cfg consists of one big line
RAIIdmem<char> line;
CALLOC(line, char, max_len);
PHYSFSX_gets(infile, line);
PHYSFSX_fgets(line,max_len,infile);
ptr = &(line[0]);
while (isspace(*ptr))
ptr++;

View file

@ -1019,7 +1019,7 @@ int read_player_file()
//read guidebot name
if (player_file_version >= 18)
PHYSFSX_readString(file, PlayerCfg.GuidebotName);
PHYSFSX_fgets(PlayerCfg.GuidebotName, file);
else
strcpy(PlayerCfg.GuidebotName,"GUIDE-BOT");
@ -1029,7 +1029,7 @@ int read_player_file()
char buf[128];
if (player_file_version >= 24)
PHYSFSX_readString(file, buf); // Just read it in fpr DPS.
PHYSFSX_fgets(buf, file); // Just read it in fpr DPS.
}
#endif
@ -1321,7 +1321,7 @@ void read_netgame_profile(netgame_info *ng)
while (!PHYSFS_eof(file))
{
memset(line, 0, 50);
PHYSFSX_gets(file, line);
PHYSFSX_fgets(line, file);
ptr = &(line[0]);
while (isspace(*ptr))
ptr++;