about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-09-05 14:01:13 -0400
committerRich Felker <dalias@aerifal.cx>2015-03-30 01:15:44 -0400
commit5a8c6f09327f7dd4d0d02f7ffeaaf9137d119c30 (patch)
tree0c770a9d25aa3796a386037e8a75fad8f4de87b0
parentf071365e66174937ffcb68c103e68573ce7dfd13 (diff)
downloadmusl-5a8c6f09327f7dd4d0d02f7ffeaaf9137d119c30.tar.gz
musl-5a8c6f09327f7dd4d0d02f7ffeaaf9137d119c30.tar.xz
musl-5a8c6f09327f7dd4d0d02f7ffeaaf9137d119c30.zip
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)
-rw-r--r--src/conf/fpathconf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/conf/fpathconf.c b/src/conf/fpathconf.c
index 28c4345c..8eb037e6 100644
--- a/src/conf/fpathconf.c
+++ b/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;
 	}