Merge branch 'fix-format-truncation'

This commit is contained in:
James R 2023-01-05 18:02:50 -08:00
commit e1b7fd79ee
5 changed files with 8 additions and 5 deletions

View file

@ -139,6 +139,7 @@ char srb2path[256] = ".";
boolean usehome = true; boolean usehome = true;
const char *pandf = "%s" PATHSEP "%s"; const char *pandf = "%s" PATHSEP "%s";
char addonsdir[MAX_WADPATH]; char addonsdir[MAX_WADPATH];
char downloaddir[sizeof addonsdir + sizeof DOWNLOADDIR_PART] = "DOWNLOAD";
// //
// EVENT HANDLING // EVENT HANDLING
@ -1361,7 +1362,7 @@ void D_SRB2Main(void)
/* and downloads in a subdirectory */ /* and downloads in a subdirectory */
snprintf(downloaddir, sizeof downloaddir, "%s%s%s", snprintf(downloaddir, sizeof downloaddir, "%s%s%s",
addonsdir, PATHSEP, "downloads"); addonsdir, PATHSEP, DOWNLOADDIR_PART);
// rand() needs seeded regardless of password // rand() needs seeded regardless of password
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));

View file

@ -99,7 +99,6 @@ static filetran_t transfer[MAXNETNODES];
INT32 fileneedednum; // Number of files needed to join the server INT32 fileneedednum; // Number of files needed to join the server
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
static tic_t lasttimeackpacketsent = 0; static tic_t lasttimeackpacketsent = 0;
char downloaddir[512] = "DOWNLOAD";
// For resuming failed downloads // For resuming failed downloads
typedef struct typedef struct

View file

@ -62,7 +62,8 @@ struct fileneeded_t
extern INT32 fileneedednum; extern INT32 fileneedednum;
extern fileneeded_t fileneeded[MAX_WADFILES]; extern fileneeded_t fileneeded[MAX_WADFILES];
extern char downloaddir[512]; #define DOWNLOADDIR_PART "downloads"
extern char downloaddir[];
extern INT32 lastfilenum; extern INT32 lastfilenum;
extern INT32 downloadcompletednum; extern INT32 downloadcompletednum;

View file

@ -80,7 +80,7 @@ typedef enum {
} menudemotype_e; } menudemotype_e;
struct menudemo_t { struct menudemo_t {
char filepath[256]; char filepath[1023 + 256]; // see M_PrepReplayList and sizeof menupath
menudemotype_e type; menudemotype_e type;
char title[65]; // Null-terminated for string prints char title[65]; // Null-terminated for string prints

View file

@ -6636,7 +6636,9 @@ void M_PrepReplayList(void)
else else
{ {
extrasmenu.demolist[i].type = MD_NOTLOADED; extrasmenu.demolist[i].type = MD_NOTLOADED;
snprintf(extrasmenu.demolist[i].filepath, 255, "%s%s", menupath, dirmenu[i] + DIR_STRING); snprintf(extrasmenu.demolist[i].filepath, sizeof extrasmenu.demolist[i].filepath,
// 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN).
"%s%.255s", menupath, dirmenu[i] + DIR_STRING);
sprintf(extrasmenu.demolist[i].title, "....."); sprintf(extrasmenu.demolist[i].title, ".....");
} }
} }