diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -287,19 +287,32 @@ return (0); } - /* - * If there's no end pointer then the buffer is coming from - * the kenv and we know it's null-terminated. - */ - if (end == NULL) + /* Ensure that strtoq() won't walk off the end */ + if (end == NULL) { + /* + * If there's no end pointer then the buffer is coming from + * the kenv and we know it's null-terminated. + */ end = *list + strlen(*list); + } else { + /* + * If there is and end pointer then the buffer is not null- + * terminated. The pointer is after the end of the buffer, so + * we need to change the last char inside the buffer to \0 if + * we can. + */ + end--; - /* Ensure that strtoq() won't walk off the end */ - if (*end != '\0') { - if (*end == '\n' || *end == ' ' || *end == ',') + switch (*end) { + case '\n': + case ' ': + case ',': *end = '\0'; - else { - printf("Blacklist not terminated, skipping\n"); + /* FALLTHROUGH */ + case '\0': + break; + default: + printf("Blacklist not terminated by '\\n', ' ' or ',', skipping\n"); *list = NULL; return (0); }