fd99905b | 22-Dec-2021 |
John Baldwin <jhb@FreeBSD.org> |
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 i
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
show more ...
|