summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2013-08-13 03:00:57 +0200
committerAnthony G. Basile <blueness@gentoo.org>2013-08-13 08:34:04 -0400
commit9b8ca4f5a942f7c6253777887f43a7ce603d428b (patch)
tree116c2116f4cad9d233432ece5e61d1d36479c7fc /src
parentb9e16e82d0ca34f6a211ead57843c59db2619c94 (diff)
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 <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/udev/mkdir.c8
1 files changed, 7 insertions, 1 deletions
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 <errno.h>
#include <stdlib.h>
#include <stdio.h>
+#include <limits.h>
#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;