From 1fa06c0afd35800cbd62bae2b6bd37105153b491 Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Mon, 29 Apr 2013 23:08:13 +0000 Subject: [PATCH] xenstore/xenstore.c: Prevent access to invalid memory region when listing an empty directory in the XenStore. Reported by: Bei Guan MFC after: 1 week --- sys/xen/xenstore/xenstore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/xen/xenstore/xenstore.c b/sys/xen/xenstore/xenstore.c index 15b7f9cbaf76..090de2372acf 100644 --- a/sys/xen/xenstore/xenstore.c +++ b/sys/xen/xenstore/xenstore.c @@ -307,7 +307,8 @@ split(char *strings, u_int len, u_int *num) const char **ret; /* Protect against unterminated buffers. */ - strings[len - 1] = '\0'; + if (len > 0) + strings[len - 1] = '\0'; /* Count the strings. */ *num = extract_strings(strings, /*dest*/NULL, len);