sgwdynspeed: fix resource leak and file stat/use race
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 22 Oct 2012 12:46:14 +0000 (14:46 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 22 Oct 2012 13:02:51 +0000 (15:02 +0200)
commit64a07a3310c68695134673eaafc971fdcbd715ad
tree94efc50fdd158491530ae54067ba9b8d13e94bb7
parent305cf135a83e4f4cf905fa486f8cf9eac15e4463
sgwdynspeed: fix resource leak and file stat/use race

Coverity:
CID 739680 (#1 of 1): Resource leak (RESOURCE_LEAK)
At (32): Variable "fd" going out of scope leaks the storage it points to.

CID 739697 (#1 of 1): Time of check time of use (TOCTOU)
At (1): Calling function "stat(char const * restrict,
                               struct stat * restrict)"
        to perform check on "fileName".
At (4): Calling function "fopen(char const * restrict,
                                char const * restrict)"
        that uses "fileName" after a check function. This can cause a
        time-of-check, time-of-use race condition.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/sgwdynspeed/src/speedFile.c