svn commit: r320665 - head/libexec/rtld-elf

Xin LI delphij at FreeBSD.org
Wed Jul 5 06:12:22 UTC 2017


Author: delphij
Date: Wed Jul  5 06:12:21 2017
New Revision: 320665
URL: https://svnweb.freebsd.org/changeset/base/320665

Log:
  In open_binary_fd: when using buffer size for strl* and snprintf,
  always use >= instead of > to avoid truncation.
  
  Reviewed by:	kib
  Differential Revision:	https://reviews.freebsd.org/D11474
  MFC after:	3 days

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Wed Jul  5 05:50:36 2017	(r320664)
+++ head/libexec/rtld-elf/rtld.c	Wed Jul  5 06:12:21 2017	(r320665)
@@ -5300,14 +5300,14 @@ open_binary_fd(const char *argv0, bool search_in_path)
 		fd = -1;
 		errno = ENOENT;
 		while ((pe = strsep(&pathenv, ":")) != NULL) {
-			if (strlcpy(binpath, pe, sizeof(binpath)) >
+			if (strlcpy(binpath, pe, sizeof(binpath)) >=
 			    sizeof(binpath))
 				continue;
 			if (binpath[0] != '\0' &&
-			    strlcat(binpath, "/", sizeof(binpath)) >
+			    strlcat(binpath, "/", sizeof(binpath)) >=
 			    sizeof(binpath))
 				continue;
-			if (strlcat(binpath, argv0, sizeof(binpath)) >
+			if (strlcat(binpath, argv0, sizeof(binpath)) >=
 			    sizeof(binpath))
 				continue;
 			fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY);


More information about the svn-src-all mailing list