Jelajahi Sumber

core: check for unexpected long value return by pathconf()

(cherry picked from commit 2ba6d4ff2727031e7bca5d3d1da016bfe508b8df)
(cherry picked from commit 718692c6d402b6942e0b1e8ebd8e64b306813495)
(cherry picked from commit f123ebae553624525ca04d34ddd4c9453eac855a)
Daniel-Constantin Mierla 7 bulan lalu
induk
melakukan
7876e1ec47
1 mengubah file dengan 2 tambahan dan 1 penghapusan
  1. 2 1
      src/core/ut.h

+ 2 - 1
src/core/ut.h

@@ -543,7 +543,8 @@ inline static int pathmax(void)
 #endif
 	if(pathmax == 0) { /* init */
 		pathmax = pathconf("/", _PC_PATH_MAX);
-		pathmax = (pathmax <= 0) ? PATH_MAX_GUESS : pathmax + 1;
+		pathmax = (pathmax <= 0 || pathmax >= INT_MAX - 1) ? PATH_MAX_GUESS
+														   : pathmax + 1;
 	}
 	return pathmax;
 }