freebsd-src/usr.sbin/kldxref
John Baldwin 257f36a7db kldxref: Properly handle reading strings near the end of an ELF file
If a string is at or near the end of an input file and the amount of
remaining data in the file is smaller than the maximum string size,
the pread(2) system call would return a short read which is treated as
an error.  Instead, add a new helper function for reading a string
which permits short reads so long as the data read from the file
contains a terminated string.

Reported by:	jrtc27
Reviewed by:	jrtc27
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44419

(cherry picked from commit 785600d0fb)
2024-04-08 11:06:41 -07:00
..
ef.c kldxref: Properly handle reading strings near the end of an ELF file 2024-04-08 11:06:41 -07:00
ef.h kldxref: Properly handle reading strings near the end of an ELF file 2024-04-08 11:06:41 -07:00
ef_aarch64.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_amd64.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_arm.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_i386.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_mips.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_obj.c kldxref: Properly handle reading strings near the end of an ELF file 2024-04-08 11:06:41 -07:00
ef_powerpc.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
ef_riscv.c kldxref: Reduce divergence between per-architecture files 2024-01-18 13:31:00 -08:00
elf.c kldxref: Properly handle reading strings near the end of an ELF file 2024-04-08 11:06:41 -07:00
fileformat Remove $FreeBSD$: one-line bare tag 2023-08-23 11:43:33 -06:00
kldxref.8 Remove $FreeBSD$: two-line nroff pattern 2023-08-23 11:43:31 -06:00
kldxref.c kldxref: fix bootstrapping on Linux with Clang 16 2024-01-18 13:31:52 -08:00
Makefile kldxref: Add arm support 2024-01-18 13:30:32 -08:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-23 11:43:30 -06:00