From: Lucas De Marchi <lucas.demarchi@xxxxxxxxx> --- libkmod/libkmod-util.c | 9 +++++---- libkmod/libkmod-util.h | 2 +- testsuite/init_module.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c index 5c680e7..45ca11a 100644 --- a/libkmod/libkmod-util.c +++ b/libkmod/libkmod-util.c @@ -323,11 +323,12 @@ static inline int is_dir(const char *path) return -errno; } -int mkdir_p(const char *path, mode_t mode) +int mkdir_p(const char *path, int len, mode_t mode) { - char *start = strdupa(path); - int len = strlen(path); - char *end = start + len; + char *start, *end; + + start = strndupa(path, len); + end = start + len; /* * scan backwards, replacing '/' with '\0' while the component doesn't diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 83c975c..4c45416 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -20,7 +20,7 @@ int read_str_ulong(int fd, unsigned long *value, int base) _must_check_ __attrib char *strchr_replace(char *s, int c, char r); bool path_is_absolute(const char *p) _must_check_ __attribute__((nonnull(1))); char *path_make_absolute_cwd(const char *p) _must_check_ __attribute__((nonnull(1))); -int mkdir_p(const char *path, mode_t mode); +int mkdir_p(const char *path, int len, mode_t mode); int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) _must_check_ __attribute__((nonnull(1,2))); char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2))); char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2))); diff --git a/testsuite/init_module.c b/testsuite/init_module.c index ebf1b94..42177e7 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -155,7 +155,7 @@ static int create_sysfs_files(const char *modname) strcpy(buf + len, modname); len += strlen(modname); - assert(mkdir_p(buf, 0755) >= 0); + assert(mkdir_p(buf, len, 0755) >= 0); strcpy(buf + len, "/initstate"); return write_one_line_file(buf, "live\n", strlen("live\n")); -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html