From 9b8ca4f5a942f7c6253777887f43a7ce603d428b Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 13 Aug 2013 03:00:57 +0200 Subject: src/udev/mkdir.c: remove usage of strndupa() strndupa() allocates memory using alloca() which is dangerous and non-conformant. Some libcs, like musl, deliberately do not implement it. Instead we allocate a buffer on the stack which is cleaned up on return. Signed-off-by: Anthony G. Basile --- src/udev/mkdir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/udev') diff --git a/src/udev/mkdir.c b/src/udev/mkdir.c index 420a9eb1b8..770ee994c4 100644 --- a/src/udev/mkdir.c +++ b/src/udev/mkdir.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "label.h" #include "util.h" @@ -90,7 +91,12 @@ static int mkdir_parents_internal(const char *prefix, const char *path, mode_t m if (e == path) return 0; - p = strndupa(path, e - path); + char buf[PATH_MAX + 1]; + p = buf; + assert(e-path < sizeof(buf)); + memcpy(buf, path, e-path); + buf[e-path] = 0; + r = is_dir(p); if (r > 0) return 0; -- cgit v1.2.3-54-g00ecf