]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
macro: calculate buffer lengths correctly 2579/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 31 Aug 2018 22:53:33 +0000 (00:53 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 31 Aug 2018 23:08:30 +0000 (01:08 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/macro.h

index 96d737267802727ec56a6c86474e9bc0b91f6416..8c8c91a6e52fcadee34c3ead1427dee10d7a0aed 100644 (file)
  *                +
  * \0           =    1
  */
-#define LXC_PROC_PID_FD_LEN (6 + INTTYPE_TO_STRLEN(pid_t) + 4 + INTTYPE_TO_STRLEN(int) + 1)
-
-/* /proc/pid-to-str/status\0 = (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1) */
-#define LXC_PROC_STATUS_LEN (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1)
-
-/* /proc/pid-to-str/attr/current = (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1) */
-#define LXC_LSMATTRLEN (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1)
+#define LXC_PROC_PID_FD_LEN \
+       (6 + INTTYPE_TO_STRLEN(pid_t) + 4 + INTTYPE_TO_STRLEN(int) + 1)
+
+/* /proc/        = 6
+ *               +
+ * <pid-as-str>  = INTTYPE_TO_STRLEN(pid_t)
+ *               +
+ * /status       = 7
+ *               +
+ * \0            = 1
+ */
+#define LXC_PROC_STATUS_LEN (6 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1)
+
+/* /proc/        = 6
+ *               +
+ * <pid-as-str>  = INTTYPE_TO_STRLEN(pid_t)
+ *               +
+ * /attr/        = 6
+ *               +
+ * /current      = 8
+ *               +
+ * \0            = 1
+ */
+#define LXC_LSMATTRLEN (6 + INTTYPE_TO_STRLEN(pid_t) + 6 + 8 + 1)
 
 #define LXC_CMD_DATA_MAX (MAXPATHLEN * 2)