diff --git a/src/path/canon.c b/src/path/canon.c index 4b3c0061..07a2a504 100644 --- a/src/path/canon.c +++ b/src/path/canon.c @@ -83,7 +83,7 @@ static inline void pop_component(char *path) * * - 0 otherwise. */ -static inline Finality next_component(char component[NAME_MAX], const char **cursor) +static inline Finality next_component(char component[NAME_MAX+1], const char **cursor) { const char *start; ptrdiff_t length; @@ -103,7 +103,7 @@ static inline Finality next_component(char component[NAME_MAX], const char **cur (*cursor)++; length = *cursor - start; - if (length >= NAME_MAX) + if (length > NAME_MAX) return -ENAMETOOLONG; /* Extract the component. */ @@ -224,7 +224,7 @@ int canonicalize(Tracee *tracee, const char *user_path, bool deref_final, finality = NOT_FINAL; while (!IS_FINAL(finality)) { Comparison comparison; - char component[NAME_MAX]; + char component[NAME_MAX+1]; finality = next_component(component, &cursor); status = (int) finality; diff --git a/src/path/proc.c b/src/path/proc.c index dc49611c..7f7ffbc3 100644 --- a/src/path/proc.c +++ b/src/path/proc.c @@ -41,7 +41,7 @@ * to @result. */ Action readlink_proc(const Tracee *tracee, char result[PATH_MAX], - const char base[PATH_MAX], const char component[NAME_MAX], + const char base[PATH_MAX], const char component[NAME_MAX+1], Comparison comparison) { const Tracee *known_tracee; diff --git a/src/path/proc.h b/src/path/proc.h index 7081dd71..592e9984 100644 --- a/src/path/proc.h +++ b/src/path/proc.h @@ -37,7 +37,7 @@ typedef enum { extern Action readlink_proc(const Tracee *tracee, char result[PATH_MAX], const char path[PATH_MAX], - const char component[NAME_MAX], Comparison comparison); + const char component[NAME_MAX+1], Comparison comparison); extern ssize_t readlink_proc2(const Tracee *tracee, char result[PATH_MAX], const char path[PATH_MAX]);