[exim-cvs] Check return from asprintf()

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] Check return from asprintf()
Gitweb: https://git.exim.org/exim.git/commitdiff/5d520e57a9347e0274fdba9e70b7054d38457f96
Commit:     5d520e57a9347e0274fdba9e70b7054d38457f96
Parent:     ea97267cea0f7e6054806504b3616f2bf9723bce
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sun Sep 23 15:44:15 2018 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Sep 23 16:01:36 2018 +0100


    Check return from asprintf()
---
 src/src/exim_dbutil.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c
index 17da205..a33c59c 100644
--- a/src/src/exim_dbutil.c
+++ b/src/src/exim_dbutil.c
@@ -260,8 +260,9 @@ ensures that Exim has exclusive use of the database before it even tries to
open it. If there is a database, there should be a lock file in existence. */

#ifdef COMPILE_UTILITY
-asprintf(CSS &dirname, "%s/db", spool_directory);
-asprintf(CSS &filename, "%s/%s.lockfile", dirname, name);
+if ( asprintf(CSS &dirname, "%s/db", spool_directory) < 0
+ || asprintf(CSS &filename, "%s/%s.lockfile", dirname, name) < 0)
+ return NULL;
#else
dirname = string_sprintf("%s/db", spool_directory);
filename = string_sprintf("%s/%s.lockfile", dirname, name);
@@ -302,7 +303,7 @@ if (rc < 0)
exclusive access to the database, so we can go ahead and open it. */

#ifdef COMPILE_UTILITY
-asprintf(CSS &filename, "%s/%s", dirname, name);
+if (asprintf(CSS &filename, "%s/%s", dirname, name) < 0) return NULL;
#else
filename = string_sprintf("%s/%s", dirname, name);
#endif