mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 07:51:03 +00:00
some more boundary checking
This commit is contained in:
parent
3c62c2be5a
commit
cd54f56b36
4 changed files with 6 additions and 6 deletions
|
@ -90,7 +90,7 @@ LoadJPG(char *origname, byte **pic, int *width, int *height)
|
|||
|
||||
/* Add the extension */
|
||||
len = strlen(filename);
|
||||
if (strcmp(filename + len - 4, ".jpg"))
|
||||
if (len >= 4 && strcmp(filename + len - 4, ".jpg"))
|
||||
{
|
||||
strncat(filename, ".jpg", sizeof(filename) - 1 - len);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height)
|
|||
filename[sizeof(filename) - 1] = '\0';
|
||||
|
||||
/* Add the extension */
|
||||
filelen = strlen(origname);
|
||||
if (strcmp(filename + filelen - 4, ".pcx"))
|
||||
filelen = strlen(filename);
|
||||
if (filelen >= 4 && strcmp(filename + filelen - 4, ".pcx"))
|
||||
{
|
||||
strncat(filename, ".pcx", sizeof(filename) - 1 - filelen);
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ LoadTGA(char *origname, byte **pic, int *width, int *height)
|
|||
name[sizeof(name) - 1] = '\0';
|
||||
|
||||
/* Add the extension */
|
||||
len = strlen(origname);
|
||||
if (strcmp(name + len - 4, ".tga"))
|
||||
len = strlen(name);
|
||||
if (len >= 4 && strcmp(name + len - 4, ".tga"))
|
||||
{
|
||||
strncat(name, ".tga", sizeof(name) - 1 - len);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ LoadWal(char *origname)
|
|||
|
||||
/* Add the extension */
|
||||
len = strlen(name);
|
||||
if (strcmp(name + len - 4, ".wal"))
|
||||
if (len >= 4 && strcmp(name + len - 4, ".wal"))
|
||||
{
|
||||
strncat(name, ".wal", sizeof(name) - 1 - len);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue