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
This commit is contained in:
Guillem Jover 2021-11-27 20:26:05 +01:00
parent 6a71b24b63
commit 43a8270317

View File

@ -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;
}