Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak from strdup when proxy is enabled #32

Open
vikivivi opened this issue Nov 5, 2023 · 1 comment
Open

Memory leak from strdup when proxy is enabled #32

vikivivi opened this issue Nov 5, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@vikivivi
Copy link

vikivivi commented Nov 5, 2023

It seem there is a memory leak when using strdup(), the memory is not free.

https://github.com/twekkel/htpdate/blob/master/htpdate.c#L831

  • You might want to perform some checking using clang in Ubuntu 22.04.
$ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.2/clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
$ sudo mkdir -p /opt/llvm
$ sudo tar -C /opt/llvm --no-same-owner --owner=root --group=root -xvf clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
$ sudo ln -sfn "clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04" /opt/llvm/clang
$ rm -f clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
  • Perform scan-build check
$ /opt/llvm/clang/bin/scan-build -o ${PWD}/static-analysis/htpdate -k -stats -internal-stats -analyze-headers -maxloop 25 -enable-checker security.FloatLoopCounter -enable-checker security.insecureAPI.DeprecatedOrUnsafeBufferHandling make CC=clang clean https
  • View the html report using /opt/llvm/clang/bin/scan-view or web browser in directory static-analysis/htpdate
@twekkel
Copy link
Owner

twekkel commented Nov 5, 2023

Thanks for taking the time to investigate. I'm aware of it, but there is no real leak... let me explain. The proxy setting (=strdup) is a one-time thing and is needed as long as the program is running. Freeing before the program terminates is not possible. So the tooling is right, the strdup() doesn't have a corresponding free(), but then again it is not possible either.

To satisfy tooling (I used Valgrind in the past), you can scan the NoLeak branch. If you look at the changes I made, you will also see that the "fix" is pointless.

@twekkel twekkel added the wontfix This will not be worked on label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants