linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] remove non-portable usage of strndupa
@ 2013-08-26 18:20 John Spencer
  2013-08-26 18:20 ` [PATCH 2/3] check if __GLIBC__ is defined before using _FILE_OFFSET_BITS John Spencer
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: John Spencer @ 2013-08-26 18:20 UTC (permalink / raw)
  To: linux-modules; +Cc: John Spencer

usage of strndupa is neither C99 nor POSIX,
so musl libc does not implement it.
it's a glibc invention, and a dangerous one since
usage of alloca() is considered bad practice.

fixes build with musl libc.

Signed-off-by: John Spencer <maillist-kmod@barfooze.de>

---
 libkmod/libkmod-util.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c
index d686250..9615d0f 100644
--- a/libkmod/libkmod-util.c
+++ b/libkmod/libkmod-util.c
@@ -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 @@ static inline int is_dir(const char *path)
 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;
 
 	/*
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-08-29  4:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-26 18:20 [PATCH 1/3] remove non-portable usage of strndupa John Spencer
2013-08-26 18:20 ` [PATCH 2/3] check if __GLIBC__ is defined before using _FILE_OFFSET_BITS John Spencer
2013-08-26 23:18   ` Lucas De Marchi
2013-08-26 23:52     ` John Spencer
2013-08-26 18:20 ` [PATCH 3/3] testsuite: fix usage of reserved names John Spencer
2013-08-26 23:07   ` Lucas De Marchi
2013-08-26 23:38     ` [PATCH 3/3 v2] " John Spencer
2013-08-26 23:49     ` [PATCH 3/3] " John Spencer
2013-08-29  4:23   ` Lucas De Marchi
2013-08-26 20:42 ` [PATCH 1/3] remove non-portable usage of strndupa Kay Sievers
2013-08-26 23:46 ` Lucas De Marchi
2013-08-27  0:16   ` John Spencer
2013-08-27  0:58     ` Kay Sievers
2013-08-27  3:35     ` Lucas De Marchi
2013-08-27  9:04       ` John Spencer
2013-08-29  3:49         ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).