Commit 691a07da authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

parsecfg: do not continue past a zero termination

When a config file line ends without newline, the parsing function could
continue reading beyond that point in memory.

Reported-by: Hanno Böck
parent 05e4137d
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
        param = line; /* parameter starts here */
        while(*line && !ISSPACE(*line))
          line++;

        if(*line) {
          *line = '\0'; /* zero terminate */

          /* to detect mistakes better, see if there's data following */
@@ -202,11 +204,12 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
          case '#': /* comment */
            break;
          default:
          warnf(operation->global, "%s:%d: warning: '%s' uses unquoted white "
                "space in the line that may cause side-effects!\n",
            warnf(operation->global, "%s:%d: warning: '%s' uses unquoted "
                  "white space in the line that may cause side-effects!\n",
                  filename, lineno, option);
          }
        }
      }

      if(!*param) {
        /* do this so getparameter can check for required parameters.