iperf icon indicating copy to clipboard operation
iperf copied to clipboard

Add error handling for close socket

Open maks-mishin opened this issue 2 years ago • 2 comments

  • Development branch: master

  • Issues fixed: add error handling for correct closing of socket s because of return with close socket leads to descriptor leak(CWE-403).

  • Brief description of code changes: added goto label with correct exit from function if necessary.

maks-mishin avatar Dec 12 '23 21:12 maks-mishin

@maks-mishin this isn't correct, mark of error_handling must be after return 0, now the function always return -1 probably you should added variable int ret and initialize it 0, and in error cases

    ret = -1;
    goto error_handling;
    ...
    error_handling:
        close(s);
        return ret;

p.s. not memleak, file descriptor leak(CWE-403)

ProjectMutilation avatar Dec 13 '23 06:12 ProjectMutilation

@ProjectMutilation, thanks for comments and advice. I will fix it in the next commit.

maks-mishin avatar Dec 13 '23 19:12 maks-mishin