From 2c651fc5008e658b90d798fb9e935811126e780d Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Mon, 3 Dec 2007 23:23:55 +0000 Subject: [PATCH] If both dbhost and dbsock were not set, a NULL deref could result Reported by: xrg Patch by: tilghman (Closes issue #11387) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@90736 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_config_pgsql.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index 4d0f16c2ce..aecff9b58d 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -720,7 +720,9 @@ static int parse_config(void) dbport = atoi(s); } - if (!ast_strlen_zero(dbhost) && !(s = ast_variable_retrieve(config, "general", "dbsock"))) { + if (!ast_strlen_zero(dbhost)) { + /* No socket needed */ + } else if (!(s = ast_variable_retrieve(config, "general", "dbsock"))) { ast_log(LOG_WARNING, "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n"); strcpy(dbsock, "/tmp/pgsql.sock");