Fix potential arithmetic overflow in the linker's plugin handling code.

PR 29101
	* libdep_plugin.c (get_libdeps): Check for overflow when computing
	amount of memory to allocate.
This commit is contained in:
Nick Clifton 2022-05-03 11:40:41 +01:00
parent 4bb461e42c
commit 46465574a9
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2022-05-03 Nick Clifton <nickc@redhat.com>
PR 29101
* libdep_plugin.c (get_libdeps): Check for overflow when computing
amount of memory to allocate.
2022-04-27 Nick Clifton <nickc@redhat.com>
PR 29006

View File

@ -99,6 +99,7 @@ get_libdeps (int fd)
arhdr ah;
int len;
unsigned long mlen;
size_t amt;
linerec *lr;
enum ld_plugin_status rc = LDPS_NO_SYMS;
@ -114,7 +115,10 @@ get_libdeps (int fd)
lseek (fd, mlen, SEEK_CUR);
continue;
}
lr = malloc (sizeof (linerec) + mlen);
amt = mlen + sizeof (linerec);
if (amt <= mlen)
return LDPS_ERR;
lr = malloc (amt);
if (!lr)
return LDPS_ERR;
lr->next = NULL;