summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-10-17 14:44:05 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-10-17 14:44:05 +0000
commit5356c27eb2103ee03fcd036afb21a63e063842ba (patch)
tree5ebc5248625cafc4edc7a0d6075316be94ba70a3
parent29f0382d7532eca906774d6b614a0e0a0a18447d (diff)
downloads6-rc-5356c27eb2103ee03fcd036afb21a63e063842ba.tar.xz
Limit prefix size to NAME_MAX
-rw-r--r--src/libs6rc/s6rc_livedir_prefixsize.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_livedir_prefixsize.c b/src/libs6rc/s6rc_livedir_prefixsize.c
index daa8481..38d060a 100644
--- a/src/libs6rc/s6rc_livedir_prefixsize.c
+++ b/src/libs6rc/s6rc_livedir_prefixsize.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
@@ -19,6 +20,7 @@ int s6rc_livedir_prefixsize (char const *live, size_t *n)
return 1 ;
}
if (!S_ISREG(st.st_mode)) return (errno = EINVAL, 0) ;
+ if (st.st_size > NAME_MAX) return (errno = ENAMETOOLONG, 0) ;
*n = st.st_size ;
return 1 ;
}