mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-29 07:41:47 +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;
|
byte *rawdata, *rgbadata, *scanline, *p, *q;
|
||||||
unsigned int rawsize, i;
|
unsigned int rawsize, i;
|
||||||
|
|
||||||
/* Add the extension */
|
strncpy(filename, origname, sizeof(filename) - 1);
|
||||||
len = strlen(origname);
|
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", sizeof(filename) - 1 - len);
|
||||||
strncat(filename, ".jpg", 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(filename, origname, 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pic = NULL;
|
*pic = NULL;
|
||||||
|
|
|
@ -38,17 +38,14 @@ LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height)
|
||||||
byte *out, *pix;
|
byte *out, *pix;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
|
||||||
|
strncpy(filename, origname, sizeof(filename) - 1);
|
||||||
|
filename[sizeof(filename) - 1] = '\0';
|
||||||
|
|
||||||
/* Add the extension */
|
/* Add the extension */
|
||||||
filelen = strlen(origname);
|
filelen = strlen(origname);
|
||||||
|
if (strcmp(filename + filelen - 4, ".pcx"))
|
||||||
if (strcmp(origname + filelen - 4, ".pcx"))
|
|
||||||
{
|
{
|
||||||
strncpy(filename, origname, 256);
|
strncat(filename, ".pcx", sizeof(filename) - 1 - filelen);
|
||||||
strncat(filename, ".pcx", 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(filename, origname, 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pic = NULL;
|
*pic = NULL;
|
||||||
|
|
|
@ -50,17 +50,14 @@ LoadTGA(char *origname, byte **pic, int *width, int *height)
|
||||||
char name[256];
|
char name[256];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
strncpy(name, origname, sizeof(name) - 1);
|
||||||
|
name[sizeof(name) - 1] = '\0';
|
||||||
|
|
||||||
/* Add the extension */
|
/* Add the extension */
|
||||||
len = strlen(origname);
|
len = strlen(origname);
|
||||||
|
if (strcmp(name + len - 4, ".tga"))
|
||||||
if (strcmp(origname + len - 4, ".tga"))
|
|
||||||
{
|
{
|
||||||
strncpy(name, origname, 256);
|
strncat(name, ".tga", sizeof(name) - 1 - len);
|
||||||
strncat(name, ".tga", 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(name, origname, 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pic = NULL;
|
*pic = NULL;
|
||||||
|
|
|
@ -35,17 +35,14 @@ LoadWal(char *origname)
|
||||||
int len;
|
int len;
|
||||||
char name[256];
|
char name[256];
|
||||||
|
|
||||||
/* Add the extension */
|
strncpy(name, origname, sizeof(name) - 1);
|
||||||
len = strlen(origname);
|
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", sizeof(name) - 1 - len);
|
||||||
strncat(name, ".wal", 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(name, origname, 256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ri.FS_LoadFile(name, (void **)&mt);
|
ri.FS_LoadFile(name, (void **)&mt);
|
||||||
|
|
Loading…
Reference in a new issue