]> git.michaelhowe.org Git - packages/o/openafs.git/commit
util: serverLog using memory after free
authorCheyenne Wills <cwills@sinenomine.net>
Tue, 25 Jun 2019 16:40:53 +0000 (10:40 -0600)
committerStephan Wiesand <stephan.wiesand@desy.de>
Thu, 25 Jul 2019 14:02:17 +0000 (10:02 -0400)
commit5d84f2a10f61e8b68b4bff18784efeb91845eef8
treed2f604913110257954758bb22abf5d5e24c143e3
parent7a613798620f16998b1f8dd636f3bb3ad7a541e1
util: serverLog using memory after free

clang's scan-build detected a "use of memory after it is freed"
condition.

The function OpenLogFile frees the variable ourName before creating a
duplicate of the name passed to it.  However there is a call that uses
ourName as the parameter: OpenLogFile(ourName).  This results in freeing
ourName then doing a strdup of the same memory location.

Test the passed parameter and if it's the same as ourName already skip
the free and strdup.

This bug was introduced in commit
    340ec2f79208ee21c3130c4b1c13995947ce426c
    "util: allocate log filename buffers"

Reviewed-on: https://gerrit.openafs.org/13659
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit f5f59cd8d336b153e2b762bb7afd16e6ab1b1ee2)

Change-Id: Ia1ae1144493fa682595b365324322d8d273c0cbb
Reviewed-on: https://gerrit.openafs.org/13675
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/util/serverLog.c