auth: Close fd on SetExtendedCellInfo write error 13/14213/2
authorAndrew Deason <adeason@sinenomine.net>
Mon, 18 May 2020 17:09:38 +0000 (12:09 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 18 May 2020 17:57:06 +0000 (13:57 -0400)
Currently, and since OpenAFS 1.0, if write() fails here, we leak the
file descriptor. A write() failure should be very unlikely, but close
the fd to make sure we avoid the leak.

Change-Id: I4e8ed4216c4aa5041232fc798a7bc59f6a5570d9
Reviewed-on: https://gerrit.openafs.org/14213
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/auth/cellconfig.c

index d570afd..1fc1592 100644 (file)
@@ -1814,6 +1814,7 @@ afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
     i = (int)strlen(acellInfo->name);
     code = write(fd, acellInfo->name, i);
     if (code != i) {
+       close(fd);
        UNLOCK_GLOBAL_MUTEX;
        return AFSCONF_FAILURE;
     }