iperf icon indicating copy to clipboard operation
iperf copied to clipboard

Memory Leak in iperf_api.c

Open kingroryg opened this issue 5 months ago • 0 comments

Location: iperf_api.c:1491 Description: Memory allocated for xbind_entry structure is not freed when strdup() fails

Code Pattern:

xbe = malloc(sizeof(struct xbind_entry));
if (!xbe) return -1;  // OK
xbe->name = strdup(optarg);
if (!xbe->name) {
    // BUG: xbe not freed
    return -1;  // MEMORY LEAK
}

The only way to "exploit" this would be:

# Repeatedly call iperf3 with bind options under memory pressure
# This would slowly leak small amounts of memory per failed call
while true; do
    iperf3 -c 127.0.0.1 --bind <some_address> &
    # Under extreme memory pressure, strdup() might fail
    # causing the small memory leak
done

kingroryg avatar Aug 04 '25 22:08 kingroryg