libpe: Avoid a potential use-after-free in pe_update_symtab().

This function appears to be unused within FreeBSD and ELFToolChain.

CID:		1418982
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2020-03-20 16:24:23 +00:00
parent a9d65c5fae
commit 388586bcd8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=359173

View file

@ -33,7 +33,7 @@ ELFTC_VCSID("$Id: pe_symtab.c 3312 2016-01-10 09:23:51Z kaiwang27 $");
int
pe_update_symtab(PE *pe, char *symtab, size_t sz, unsigned int nsym)
{
PE_Scn *ps;
PE_Scn *ps, *pstmp;
PE_SecBuf *sb;
PE_SecHdr *sh;
@ -48,7 +48,7 @@ pe_update_symtab(PE *pe, char *symtab, size_t sz, unsigned int nsym)
}
/* Remove the old symbol table. */
STAILQ_FOREACH(ps, &pe->pe_scn, ps_next) {
STAILQ_FOREACH_SAFE(ps, &pe->pe_scn, ps_next, pstmp) {
if (ps->ps_ndx == 0xFFFFFFFFU)
libpe_release_scn(ps);
}