mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 14:00:58 +00:00
some strncpy/strncat fixes
This commit is contained in:
parent
d4c5960f8f
commit
9803652781
4 changed files with 22 additions and 34 deletions
|
@ -85,17 +85,14 @@ LoadJPG(char *origname, byte **pic, int *width, int *height)
|
|||
byte *rawdata, *rgbadata, *scanline, *p, *q;
|
||||
unsigned int rawsize, i;
|
||||
|
||||
/* Add the extension */
|
||||
len = strlen(origname);
|
||||
strncpy(filename, origname, sizeof(filename) - 1);
|
||||
filename[sizeof(filename) - 1] = '\0';
|
||||
|
||||
if (strcmp(origname + len - 4, ".jpg"))
|
||||
/* Add the extension */
|
||||
len = strlen(filename);
|
||||
if (strcmp(filename + len - 4, ".jpg"))
|
||||
{
|
||||
strncpy(filename, origname, 256);
|
||||
strncat(filename, ".jpg", 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(filename, origname, 256);
|
||||
strncat(filename, ".jpg", sizeof(filename) - 1 - len);
|
||||
}
|
||||
|
||||
*pic = NULL;
|
||||
|
|
|
@ -38,17 +38,14 @@ LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height)
|
|||
byte *out, *pix;
|
||||
char filename[256];
|
||||
|
||||
strncpy(filename, origname, sizeof(filename) - 1);
|
||||
filename[sizeof(filename) - 1] = '\0';
|
||||
|
||||
/* Add the extension */
|
||||
filelen = strlen(origname);
|
||||
|
||||
if (strcmp(origname + filelen - 4, ".pcx"))
|
||||
if (strcmp(filename + filelen - 4, ".pcx"))
|
||||
{
|
||||
strncpy(filename, origname, 256);
|
||||
strncat(filename, ".pcx", 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(filename, origname, 256);
|
||||
strncat(filename, ".pcx", sizeof(filename) - 1 - filelen);
|
||||
}
|
||||
|
||||
*pic = NULL;
|
||||
|
|
|
@ -50,17 +50,14 @@ LoadTGA(char *origname, byte **pic, int *width, int *height)
|
|||
char name[256];
|
||||
int len;
|
||||
|
||||
strncpy(name, origname, sizeof(name) - 1);
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
|
||||
/* Add the extension */
|
||||
len = strlen(origname);
|
||||
|
||||
if (strcmp(origname + len - 4, ".tga"))
|
||||
if (strcmp(name + len - 4, ".tga"))
|
||||
{
|
||||
strncpy(name, origname, 256);
|
||||
strncat(name, ".tga", 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(name, origname, 256);
|
||||
strncat(name, ".tga", sizeof(name) - 1 - len);
|
||||
}
|
||||
|
||||
*pic = NULL;
|
||||
|
|
|
@ -35,17 +35,14 @@ LoadWal(char *origname)
|
|||
int len;
|
||||
char name[256];
|
||||
|
||||
/* Add the extension */
|
||||
len = strlen(origname);
|
||||
strncpy(name, origname, sizeof(name) - 1);
|
||||
name[sizeof(name) - 1] = '\0';
|
||||
|
||||
if (strcmp(origname + len - 4, ".wal"))
|
||||
/* Add the extension */
|
||||
len = strlen(name);
|
||||
if (strcmp(name + len - 4, ".wal"))
|
||||
{
|
||||
strncpy(name, origname, 256);
|
||||
strncat(name, ".wal", 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(name, origname, 256);
|
||||
strncat(name, ".wal", sizeof(name) - 1 - len);
|
||||
}
|
||||
|
||||
ri.FS_LoadFile(name, (void **)&mt);
|
||||
|
|
Loading…
Reference in a new issue