void-packages/srcpkgs/kmod/patches/kmod.patch

33 lines
795 B
Diff

remove non-portable usage of strndupa
usage of strndupa is neither C99 nor POSIX,
it's a glibc invention, and a dangerous one since
alloca() is used behind the scenes which does not
give any guarantuees that it won't overflow the
stack.
--- libkmod/libkmod-util.c 2013-08-26 16:03:22.239000003 +0000
+++ libkmod/libkmod-util.c 2013-08-26 16:07:26.684000003 +0000
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <limits.h>
#include <ctype.h>
#include "libkmod.h"
@@ -323,8 +324,11 @@
int mkdir_p(const char *path, int len, mode_t mode)
{
char *start, *end;
-
- start = strndupa(path, len);
+ char buf[PATH_MAX+1];
+ snprintf(buf, sizeof buf, "%s", path);
+ assert(len < sizeof(buf));
+ buf[len] = 0;
+ start = buf;
end = start + len;
/*