stages/*: change license to Apache 2.0
[dragora.git] / patches / kmod / kmod.patch
blob38a7988643e27f90d58c25c67c7cdb172f5c71fb
1 remove non-portable usage of strndupa
3 usage of strndupa is neither C99 nor POSIX,
4 it's a glibc invention, and a dangerous one since
5 alloca() is used behind the scenes which does not
6 give any guarantuees that it won't overflow the
7 stack.
9 --- kmod-15.org/libkmod/libkmod-util.c 2013-08-26 16:03:22.239000003 +0000
10 +++ kmod-15/libkmod/libkmod-util.c 2013-08-26 16:07:26.684000003 +0000
11 @@ -28,6 +28,7 @@
12 #include <unistd.h>
13 #include <errno.h>
14 #include <string.h>
15 +#include <limits.h>
16 #include <ctype.h>
18 #include "libkmod.h"
19 @@ -323,8 +324,11 @@
20 int mkdir_p(const char *path, int len, mode_t mode)
22 char *start, *end;
24 - start = strndupa(path, len);
25 + char buf[PATH_MAX+1];
26 + snprintf(buf, sizeof buf, "%s", path);
27 + assert(len < sizeof(buf));
28 + buf[len] = 0;
29 + start = buf;
30 end = start + len;