]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fd-util: introduce FDNAME_MAX
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 May 2021 01:19:19 +0000 (10:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 May 2021 01:19:19 +0000 (10:19 +0900)
src/basic/fd-util.c
src/basic/fd-util.h

index d63f012ad5199f00a4809b8f48cbd9de37b5084a..1a873601b275479c76b400c1f958b02877149013 100644 (file)
@@ -454,7 +454,7 @@ bool fdname_is_valid(const char *s) {
                         return false;
         }
 
-        return p - s < 256;
+        return p - s <= FDNAME_MAX;
 }
 
 int fd_get_path(int fd, char **ret) {
index f05c2b5a15dc7ab6a03a96535c6b74d6f5d9af4d..aa8e082b38d665b6b56e729faa4d24d153537767 100644 (file)
@@ -8,6 +8,9 @@
 
 #include "macro.h"
 
+/* maximum length of fdname */
+#define FDNAME_MAX 255
+
 /* Make sure we can distinguish fd 0 and NULL */
 #define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
 #define PTR_TO_FD(p) (PTR_TO_INT(p)-1)