From 840fb4d47b612f53f46ef1bea2fac17a4dcf5ce5 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Mon, 11 Jul 2022 19:35:10 -0400 Subject: doom: Fix a potential buffer trashing in the doom plugin (caught by GCC12's -Waddress) Change-Id: I122b44324c60c668ed4a066aa6301d40cb7597ba --- apps/plugins/doom/d_deh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/plugins/doom/d_deh.c b/apps/plugins/doom/d_deh.c index 1a399e3b49..0a67aa0aad 100644 --- a/apps/plugins/doom/d_deh.c +++ b/apps/plugins/doom/d_deh.c @@ -63,7 +63,7 @@ char* strlwr(char* str) typedef struct { const byte *inp; // Pointer to string size_t size; // Bytes remaining in string - int fd; // Current file descriptor + int fd; // Current file descriptor } DEHFILE; // killough 10/98: emulate IO whether input really comes from a file or not @@ -2868,6 +2868,7 @@ boolean deh_GetData(char *s, char *k, uint_64_t *l, char **strval, int fpout) if (*t == '=') break; buffer[i] = *t; // copy it } + if (i == 0) i = 1; /* Just in case */ buffer[--i] = '\0'; // terminate the key before the '=' if (!*t) // end of string with no equal sign { -- cgit v1.2.3