fix potential buffer overflow loading config file
This commit is contained in:
+5
-16
@@ -1,8 +1,8 @@
|
|||||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.4 $ $NHDT-Date: 1576287569 2019/12/14 01:39:29 $
|
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.4 $ $NHDT-Date: 1576287569 2019/12/14 01:39:29 $
|
||||||
|
|
||||||
This fixes36.4 file is here to capture information about updates in the 3.6.x
|
fixes36.4 contains a terse summary of changes made to 3.6.3 in order to
|
||||||
lineage following the release of 3.6.3 in December 2019. Hypothetical version
|
produce 3.6.4.
|
||||||
3.6.4 may not be released, in which case these fixes will appear in 3.7.0.
|
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -15,11 +15,7 @@ message "your knapsack can't accomodate any more items" when picking stuff up
|
|||||||
or removing such from container was inaccurate if there was some gold
|
or removing such from container was inaccurate if there was some gold
|
||||||
pending; vary the message rather than add more convoluted pickup code
|
pending; vary the message rather than add more convoluted pickup code
|
||||||
dozen-ish assorted spelling/typo fixes in messages and source comments
|
dozen-ish assorted spelling/typo fixes in messages and source comments
|
||||||
flying hero could not use a hole deliberately with '>'
|
fix potential buffer overflow when parsing run-time configuration file
|
||||||
|
|
||||||
|
|
||||||
Fixes to Post-3.6.3 Problems that Were Exposed Via git Repository
|
|
||||||
------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
Platform- and/or Interface-Specific Fixes or Features
|
Platform- and/or Interface-Specific Fixes or Features
|
||||||
@@ -30,13 +26,6 @@ allow run-from-removable-device on Windows
|
|||||||
|
|
||||||
General New Features
|
General New Features
|
||||||
--------------------
|
--------------------
|
||||||
|
none
|
||||||
|
|
||||||
NetHack Community Patches (or Variation) Included
|
|
||||||
-------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
Code Cleanup and Reorganization
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+23
-12
@@ -2309,10 +2309,14 @@ char *origbuf;
|
|||||||
int len;
|
int len;
|
||||||
boolean retval = TRUE;
|
boolean retval = TRUE;
|
||||||
|
|
||||||
|
while (*origbuf == ' ' || *origbuf == '\t') /* skip leading whitespace */
|
||||||
|
++origbuf; /* (caller probably already did this) */
|
||||||
|
(void) strncpy(buf, origbuf, sizeof buf - 1);
|
||||||
|
buf[sizeof buf - 1] = '\0'; /* strncpy not guaranteed to NUL terminate */
|
||||||
/* convert any tab to space, condense consecutive spaces into one,
|
/* convert any tab to space, condense consecutive spaces into one,
|
||||||
remove leading and trailing spaces (exception: if there is nothing
|
remove leading and trailing spaces (exception: if there is nothing
|
||||||
but spaces, one of them will be kept even though it leads/trails) */
|
but spaces, one of them will be kept even though it leads/trails) */
|
||||||
mungspaces(strcpy(buf, origbuf));
|
mungspaces(buf);
|
||||||
|
|
||||||
/* find the '=' or ':' */
|
/* find the '=' or ':' */
|
||||||
bufp = find_optparam(buf);
|
bufp = find_optparam(buf);
|
||||||
@@ -3034,7 +3038,11 @@ boolean
|
|||||||
proc_wizkit_line(buf)
|
proc_wizkit_line(buf)
|
||||||
char *buf;
|
char *buf;
|
||||||
{
|
{
|
||||||
struct obj *otmp = readobjnam(buf, (struct obj *) 0);
|
struct obj *otmp;
|
||||||
|
|
||||||
|
if (strlen(buf) >= BUFSZ)
|
||||||
|
buf[BUFSZ - 1] = '\0';
|
||||||
|
otmp = readobjnam(buf, (struct obj *) 0);
|
||||||
|
|
||||||
if (otmp) {
|
if (otmp) {
|
||||||
if (otmp != &zeroobj)
|
if (otmp != &zeroobj)
|
||||||
@@ -3142,22 +3150,23 @@ boolean FDECL((*proc), (char *));
|
|||||||
|
|
||||||
/* merge now read line with previous ones, if necessary */
|
/* merge now read line with previous ones, if necessary */
|
||||||
if (!ignoreline) {
|
if (!ignoreline) {
|
||||||
len = (int) strlen(inbuf) + 1;
|
len = (int) strlen(ep) + 1; /* +1: final '\0' */
|
||||||
if (buf)
|
if (buf)
|
||||||
len += (int) strlen(buf);
|
len += (int) strlen(buf) + 1; /* +1: space */
|
||||||
tmpbuf = (char *) alloc(len);
|
tmpbuf = (char *) alloc(len);
|
||||||
|
*tmpbuf = '\0';
|
||||||
if (buf) {
|
if (buf) {
|
||||||
Sprintf(tmpbuf, "%s %s", buf, inbuf);
|
Strcat(strcpy(tmpbuf, buf), " ");
|
||||||
free(buf);
|
free(buf);
|
||||||
} else
|
}
|
||||||
Strcpy(tmpbuf, inbuf);
|
buf = strcat(tmpbuf, ep);
|
||||||
buf = tmpbuf;
|
buf[sizeof inbuf - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (morelines || (ignoreline && !oldline))
|
if (morelines || (ignoreline && !oldline))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (handle_config_section(ep)) {
|
if (handle_config_section(buf)) {
|
||||||
free(buf);
|
free(buf);
|
||||||
buf = (char *) 0;
|
buf = (char *) 0;
|
||||||
continue;
|
continue;
|
||||||
@@ -3179,11 +3188,11 @@ boolean FDECL((*proc), (char *));
|
|||||||
}
|
}
|
||||||
bufp++;
|
bufp++;
|
||||||
if (config_section_chosen)
|
if (config_section_chosen)
|
||||||
free(config_section_chosen);
|
free(config_section_chosen), config_section_chosen = 0;
|
||||||
section = choose_random_part(bufp, ',');
|
section = choose_random_part(bufp, ',');
|
||||||
if (section)
|
if (section) {
|
||||||
config_section_chosen = dupstr(section);
|
config_section_chosen = dupstr(section);
|
||||||
else {
|
} else {
|
||||||
config_error_add("No config section to choose");
|
config_error_add("No config section to choose");
|
||||||
rv = FALSE;
|
rv = FALSE;
|
||||||
}
|
}
|
||||||
@@ -3300,6 +3309,8 @@ int which_set;
|
|||||||
struct symparse *symp;
|
struct symparse *symp;
|
||||||
char *bufp, *commentp, *altp;
|
char *bufp, *commentp, *altp;
|
||||||
|
|
||||||
|
if (strlen(buf) >= BUFSZ)
|
||||||
|
buf[BUFSZ - 1] = '\0';
|
||||||
/* convert each instance of whitespace (tabs, consecutive spaces)
|
/* convert each instance of whitespace (tabs, consecutive spaces)
|
||||||
into a single space; leading and trailing spaces are stripped */
|
into a single space; leading and trailing spaces are stripped */
|
||||||
mungspaces(buf);
|
mungspaces(buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user