[asterisk-bugs] [Asterisk 0010310]: Invalid free of connection pointer

noreply at bugs.digium.com noreply at bugs.digium.com
Fri Jul 27 11:46:54 CDT 2007


The following issue has been ASSIGNED. 
====================================================================== 
http://bugs.digium.com/view.php?id=10310 
====================================================================== 
Reported By:                prashant_jois
Assigned To:                file
====================================================================== 
Project:                    Asterisk
Issue ID:                   10310
Category:                   CDR/cdr_pgsql
Reproducibility:            random
Severity:                   crash
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.9  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             07-26-2007 12:14 CDT
Last Modified:              07-27-2007 11:46 CDT
====================================================================== 
Summary:                    Invalid free of connection pointer
Description: 
This may or may not cause a crash, but invalid memory is being accessed on
failure to connect to the PGSQL database.  

Specifically -

lines 88-92:

   pgerror = PQerrorMessage(conn);
   PQfinish(conn);
   ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s.
Calls will not be logged!\n", pghostname);
   ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);

---------------

PQfinish should come after line 92, because pgerror is a pointer to one of
the fields in conn:


   pgerror = PQerrorMessage(conn);
   ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s.
Calls will not be logged!\n", pghostname);
   ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
   PQfinish(conn);

---------------

The same goes for lines 148-152. It should be:

   pgerror = PQerrorMessage(conn);
   ast_log(LOG_ERROR, "cdr_pgsql: Unable to reconnect to database server
%s. Calls will not be logged!\n", pghostname);
   ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
   PQfinish(conn);


======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0010295 segfault on reload
====================================================================== 

---------------------------------------------------------------------- 
 svnbot - 07-27-07 11:46  
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 77540

------------------------------------------------------------------------
r77540 | file | 2007-07-27 11:46:53 -0500 (Fri, 27 Jul 2007) | 6 lines

(closes issue http://bugs.digium.com/view.php?id=10310)
Reported by: prashant_jois
Patches:
      cdr_pgsql.patch uploaded by prashant (license 114)
Finish the Postgresql connection after the log messages are printed so we
don't access invalid memory.

------------------------------------------------------------------------ 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-27-07 11:46  svnbot         Checkin                                      
07-27-07 11:46  svnbot         Note Added: 0067984                          
07-27-07 11:46  svnbot         Status                   new => assigned     
07-27-07 11:46  svnbot         Assigned To               => file            
======================================================================




More information about the asterisk-bugs mailing list