mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-09 03:08:38 +01:00
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:
parent
6a71b24b63
commit
43a8270317
@ -43,10 +43,6 @@
|
|||||||
|
|
||||||
#include "local-elf.h"
|
#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.
|
/* Note: This function is used by libkvm0, so we need to export it.
|
||||||
* It is not declared in the include files though. */
|
* It is not declared in the include files though. */
|
||||||
int __fdnlist(int, struct nlist *);
|
int __fdnlist(int, struct nlist *);
|
||||||
@ -153,7 +149,7 @@ __fdnlist(int fd, struct nlist *list)
|
|||||||
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
|
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
|
||||||
|
|
||||||
/* Make sure it's not too big to mmap */
|
/* 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;
|
errno = EFBIG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -186,7 +182,7 @@ __fdnlist(int fd, struct nlist *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for files too large to mmap. */
|
/* Check for files too large to mmap. */
|
||||||
if (symstrsize > SIZE_T_MAX || symstrsize > st.st_size) {
|
if (symstrsize > st.st_size) {
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user