HomeFreeBSD

libiscsiutil: Fix a memory leak with negotiation keys.

Description

libiscsiutil: Fix a memory leak with negotiation keys.

When keys are loaded from a received PDU, a copy of the received keys
block is saved in the keys struct and the name and value pointers
point into that saved block. Freeing the keys frees this block.

However, when keys are added to a keys struct to build a set of keys
later sent in a PDU, the keys data block pointer is not used and
individual key names and values hold allocated strings. When the keys
structure was freed, all of these individual key name and value
strings were leaked.

Instead, allocate copies of strings for names and values when parsing
a set of keys from a received PDU and free all of the individual key
name and value strings when deleting a set of keys.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D33545

Details

Provenance
jhbAuthored on Dec 22 2021, 6:41 PM
Reviewer
mav
Differential Revision
D33545: libiscsiutil: Fix a memory leak with negotiation keys.
Parents
rG6378393308bc: Add an internal libiscsiutil library.
Branches
Unknown
Tags
Unknown