mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-21 19:41:14 +00:00
Use snprintf and a larger buffer for file size.
In practice it would likely never overflow, but if you happen to have an implausible large demo in folder it could.
This commit is contained in:
parent
3672234c24
commit
317ca00298
1 changed files with 5 additions and 5 deletions
10
fteqtv/qw.c
10
fteqtv/qw.c
|
@ -2728,7 +2728,7 @@ I've removed the following from this function as it covered the menu (~Moodles):
|
|||
else if (!strcmp(command, "guidemos"))
|
||||
{
|
||||
int maxshowndemos;
|
||||
char sizestr[7];
|
||||
char sizestr[11];
|
||||
int start;
|
||||
int i;
|
||||
|
||||
|
@ -2776,13 +2776,13 @@ I've removed the following from this function as it covered the menu (~Moodles):
|
|||
if (i >= cluster->availdemoscount)
|
||||
break;
|
||||
if (cluster->availdemos[i].size < 1024)
|
||||
sprintf(sizestr, "%4ib", cluster->availdemos[i].size);
|
||||
snprintf(sizestr, sizeof(sizestr), "%4ib", cluster->availdemos[i].size);
|
||||
else if (cluster->availdemos[i].size < 1024*1024)
|
||||
sprintf(sizestr, "%4ikb", cluster->availdemos[i].size/1024);
|
||||
snprintf(sizestr, sizeof(sizestr), "%4ikb", cluster->availdemos[i].size/1024);
|
||||
else if (cluster->availdemos[i].size < 1024*1024*1024)
|
||||
sprintf(sizestr, "%4imb", cluster->availdemos[i].size/(1024*1024));
|
||||
snprintf(sizestr, sizeof(sizestr), "%4imb", cluster->availdemos[i].size/(1024*1024));
|
||||
else// if (cluster->availdemos[i].size < 1024*1024*1024*1024)
|
||||
sprintf(sizestr, "%4igb", cluster->availdemos[i].size/(1024*1024*1024));
|
||||
snprintf(sizestr, sizeof(sizestr), "%4igb", cluster->availdemos[i].size/(1024*1024*1024));
|
||||
// else
|
||||
// *sizestr = 0;
|
||||
QW_StuffcmdToViewer(v, "menutext 32 %i \"%6s %-30s\" \"demo %s\"\n", (i-start)*8 + 52+16, sizestr, cluster->availdemos[i].name, cluster->availdemos[i].name);
|
||||
|
|
Loading…
Reference in a new issue