Commit 539e3ee7 authored by Youfu Zhang's avatar Youfu Zhang Committed by David Woodhouse

NUL-terminate gai->value for OPT_RESOLVE, fix out-of-bound read

Signed-off-by: default avatarYoufu Zhang <zhangyoufu@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent a01a167b
......@@ -1174,7 +1174,7 @@ int main(int argc, char **argv)
fprintf(stderr, _("Missing colon in resolve option\n"));
exit(1);
}
gai = malloc(sizeof(*gai) + strlen(config_arg));
gai = malloc(sizeof(*gai) + strlen(config_arg) + 1);
if (!gai) {
fprintf(stderr, _("Failed to allocate memory\n"));
exit(1);
......@@ -1182,7 +1182,7 @@ int main(int argc, char **argv)
gai->next = gai_overrides;
gai_overrides = gai;
gai->option = (void *)(gai + 1);
memcpy(gai->option, config_arg, strlen(config_arg));
memcpy(gai->option, config_arg, strlen(config_arg) + 1);
gai->option[ip - config_arg] = 0;
gai->value = gai->option + (ip - config_arg) + 1;
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment