]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
nlist: Remove condition which is always true
authorGuillem Jover <guillem@hadrons.org>
Sat, 27 Nov 2021 19:26:05 +0000 (20:26 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sat, 27 Nov 2021 22:36:34 +0000 (23:36 +0100)
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
src/nlist.c

index 8012d5a9854633ea49a9a050db16a3cd3aa6fe55..1cb9d188a4a251af7c60d7c48151ac505c43a252 100644 (file)
 
 #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;
        }