Commit 43a827031779650e63a5f787fc1959d146355153

Guillem Jover 2021-11-27T20:26:05

nlist: Remove condition which is always true The nlist() function is limited to handle ELF binaries of the same class as size as the size_t of the architecture built. In addition the SIZE_T_MAX macro is BSD specific, and was falling back to the wrong constant on most 64-bit non-BSD systems. Warned-by: gcc

diff --git a/src/nlist.c b/src/nlist.c
index 8012d5a..1cb9d18 100644
--- a/src/nlist.c
+++ b/src/nlist.c
@@ -43,10 +43,6 @@
 
 #include "local-elf.h"
 
-#ifndef SIZE_T_MAX
-#define SIZE_T_MAX 0xffffffffU
-#endif
-
 /* Note: This function is used by libkvm0, so we need to export it.
  * It is not declared in the include files though. */
 int __fdnlist(int, struct nlist *);
@@ -153,7 +149,7 @@ __fdnlist(int fd, struct nlist *list)
 	shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
 
 	/* Make sure it's not too big to mmap */
-	if (shdr_size > SIZE_T_MAX || shdr_size > st.st_size) {
+	if (shdr_size > st.st_size) {
 		errno = EFBIG;
 		return (-1);
 	}
@@ -186,7 +182,7 @@ __fdnlist(int fd, struct nlist *list)
 	}
 
 	/* Check for files too large to mmap. */
-	if (symstrsize > SIZE_T_MAX || symstrsize > st.st_size) {
+	if (symstrsize > st.st_size) {
 		errno = EFBIG;
 		goto done;
 	}