1
0
Эх сурвалжийг харах

fix off-by-one in bounds check in fpathconf

this error resulted in an out-of-bounds read, as opposed to a reported
error, when calling the function with an argument one greater than the
max valid index.

(cherry picked from commit 3bed89aa7456d9fe30e550cb5e21f8911036695b)
Rich Felker 10 жил өмнө
parent
commit
5a8c6f0932
1 өөрчлөгдсөн 1 нэмэгдсэн , 1 устгасан
  1. 1 1
      src/conf/fpathconf.c

+ 1 - 1
src/conf/fpathconf.c

@@ -27,7 +27,7 @@ long fpathconf(int fd, int name)
 		[_PC_SYMLINK_MAX] = SYMLINK_MAX,
 		[_PC_2_SYMLINKS] = 1
 	};
-	if (name > sizeof(values)/sizeof(values[0])) {
+	if (name >= sizeof(values)/sizeof(values[0])) {
 		errno = EINVAL;
 		return -1;
 	}