mirror of
https://github.com/curl/curl.git
synced 2025-09-22 03:52:42 +03:00
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
This commit is contained in:
parent
05e4137d31
commit
691a07dac6
|
@ -187,24 +187,27 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||||
param = line; /* parameter starts here */
|
param = line; /* parameter starts here */
|
||||||
while(*line && !ISSPACE(*line))
|
while(*line && !ISSPACE(*line))
|
||||||
line++;
|
line++;
|
||||||
*line = '\0'; /* zero terminate */
|
|
||||||
|
|
||||||
/* to detect mistakes better, see if there's data following */
|
if(*line) {
|
||||||
line++;
|
*line = '\0'; /* zero terminate */
|
||||||
/* pass all spaces */
|
|
||||||
while(*line && ISSPACE(*line))
|
/* to detect mistakes better, see if there's data following */
|
||||||
line++;
|
line++;
|
||||||
|
/* pass all spaces */
|
||||||
|
while(*line && ISSPACE(*line))
|
||||||
|
line++;
|
||||||
|
|
||||||
switch(*line) {
|
switch(*line) {
|
||||||
case '\0':
|
case '\0':
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '#': /* comment */
|
case '#': /* comment */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
warnf(operation->global, "%s:%d: warning: '%s' uses unquoted white "
|
warnf(operation->global, "%s:%d: warning: '%s' uses unquoted "
|
||||||
"space in the line that may cause side-effects!\n",
|
"white space in the line that may cause side-effects!\n",
|
||||||
filename, lineno, option);
|
filename, lineno, option);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user