pppd: Check tdb pointer before closing
authorAlfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
Thu, 6 Jun 2019 15:36:29 +0000 (17:36 +0200)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 19 Oct 2019 04:52:21 +0000 (15:52 +1100)
Check that pointer to the tdb is not NULL before calling tdb_close().
It is possible that the file could not be opened/created due to
permission issues. This change prevents the crash that happens in that
case.

Signed-off-by: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
pppd/main.c

index 41be5328d4b8d7b7af89935cc66f093a5b932da9..1b3f1e54bdd3250cb41fb986b89b3aaff355128e 100644 (file)
@@ -1574,7 +1574,8 @@ safe_fork(int infd, int outfd, int errfd)
        /* Executing in the child */
        sys_close();
 #ifdef USE_TDB
-       tdb_close(pppdb);
+       if (pppdb != NULL)
+               tdb_close(pppdb);
 #endif
 
        /* make sure infd, outfd and errfd won't get tromped on below */