]> git.ipfire.org Git - thirdparty/freeradius-server.git/commit
Fix dangling pointer issue (#4786)
authorJames Jones <jejones3141@gmail.com>
Tue, 25 Oct 2022 22:22:44 +0000 (17:22 -0500)
committerGitHub <noreply@github.com>
Tue, 25 Oct 2022 22:22:44 +0000 (18:22 -0400)
commit332f13652bfbe99dcd0e5221bdd6c5bb1cc24c35
treef72638ba02e84ec5dea39aa8027182ebd5071b2a
parenta49eda4ddb20940ebb9395eab32b752db5ec02aa
Fix dangling pointer issue (#4786)

clang may not realize that memcpy() doesn't keep the pointers handed
to it around, so there's no risk of the address of an auto being kept
past the caller's return, hence the "dangling pointer" warning.

Instead, head it off at the pass by immediately returning if len
is zero, so in needn't be set to the address of an auto; the only
explicit passing of NULL for in passes 0 for len. (Comments explain
how if len == 0, nothing changes in the context.) One could argue
for checking in rather than or in addition to checking len... OTOH,
shouldn't passing NULL and a non-zero len break loudly?
src/lib/util/sha1.c