inp_readline() Correct slashguard feature

Protect against invalid reads by checking the length.
This commit is contained in:
Michael Vetter
2020-04-21 16:47:18 +02:00
parent f27bd92731
commit 813fd637a1

View File

@@ -197,12 +197,14 @@ inp_readline(void)
if (inp_line) { if (inp_line) {
if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) { if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) {
if (strlen(inp_line) > 1) {
char *res = (char*) memchr (inp_line+1, '/', 3); char *res = (char*) memchr (inp_line+1, '/', 3);
if (res) { if (res) {
cons_show("Your text contains a slash in the first 4 characters"); cons_show("Your text contains a slash in the first 4 characters");
return NULL; return NULL;
} }
} }
}
return strdup(inp_line); return strdup(inp_line);
} else { } else {
return NULL; return NULL;