Advanced Rogue family: fix some potential buffer overflows.
Some code for determining the score file location assumed that PATH_MAX would be less than 1024, which cannot be guaranteed. Advanced Rogue 5 and 7, and XRogue, have had the buffers for the file name enlarged. UltraRogue never called the functions, so the code has been deleted instead.
This commit is contained in:
parent
2b6d8bcb77
commit
3dfd8fd09b
13 changed files with 51 additions and 78 deletions
|
|
@ -401,54 +401,6 @@ md_shellescape()
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
directory_exists(char *dirname)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (stat(dirname, &sb) == 0) /* path exists */
|
||||
return (sb.st_mode & S_IFDIR);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
char *
|
||||
md_getroguedir()
|
||||
{
|
||||
static char path[1024];
|
||||
char *end,*home;
|
||||
|
||||
if ( (home = getenv("ROGUEHOME")) != NULL)
|
||||
{
|
||||
if (*home)
|
||||
{
|
||||
strncpy(path, home, PATH_MAX - 20);
|
||||
|
||||
end = &path[strlen(path)-1];
|
||||
|
||||
while( (end >= path) && ((*end == '/') || (*end == '\\')))
|
||||
*end-- = '\0';
|
||||
|
||||
if (directory_exists(path))
|
||||
return(path);
|
||||
}
|
||||
}
|
||||
|
||||
if (directory_exists("/var/games/roguelike"))
|
||||
return("/var/games/roguelike");
|
||||
if (directory_exists("/var/lib/roguelike"))
|
||||
return("/var/lib/roguelike");
|
||||
if (directory_exists("/var/roguelike"))
|
||||
return("/var/roguelike");
|
||||
if (directory_exists("/usr/games/lib"))
|
||||
return("/usr/games/lib");
|
||||
if (directory_exists("/games/roguelik"))
|
||||
return("/games/roguelik");
|
||||
if (directory_exists(md_gethomedir()))
|
||||
return(md_gethomedir());
|
||||
return("");
|
||||
}
|
||||
|
||||
char *
|
||||
md_getrealname(int uid)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue