1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-12-22 07:10:49 +01:00

Only parse arguments if index actually is numeric

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-11-03 19:25:15 +01:00
parent 24e98f1e5b
commit b3773d09ea

View file

@ -84,15 +84,16 @@ static int normalize_line(rdline_t *t)
} else if (c == '%') {
*(dst++) = c;
c = *(src++);
if (c != '%' && !isdigit(c)) {
if (isdigit(c)) {
if ((c - '0') >= t->argc) {
errstr = "argument out of range";
goto fail;
}
ret += strlen(t->argv[c - '0']);
} else if (c != '%') {
errstr = "expected digit after '%%'";
goto fail;
}
if (isdigit(c) && (c - '0') >= t->argc) {
errstr = "argument out of range";
goto fail;
}
ret += strlen(t->argv[c - '0']);
} else if (string && c == '\\' && *src != '\0') {
*(dst++) = c;
c = *(src++);