From b5c3bcda7d37cbcad68ce841f9bcd679f12400f4 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 27 Jun 2014 11:44:06 +0100 Subject: [PATCH] Ensure that path[0] == '\0' upon entry to delete_content() As a quick fix, staticise path to ensure that it is zero-filled upon initial entry to the function. In rare cases there's a possible buffer overflow and/or path mess up on the first call to strlcat() with path[0] != '\0'. The proper fix is to utilize util/recurse.c but the traversal order cannot be specified at the moment. Expect a better fix in the future. --- switch_root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/switch_root.c b/switch_root.c index 6ad40a9..49a49e7 100644 --- a/switch_root.c +++ b/switch_root.c @@ -17,7 +17,7 @@ static void delete_content(const char *dir, dev_t curdevice) { - char path[PATH_MAX]; + static char path[PATH_MAX]; DIR *d; struct stat st; struct dirent *dent;