Summary: | ASTERISK-09964: Invalid free of connection pointer | ||
Reporter: | Prashant Jois (prashant_jois) | Labels: | |
Date Opened: | 2007-07-26 12:14:32 | Date Closed: | 2007-07-27 11:48:06 |
Priority: | Critical | Regression? | No |
Status: | Closed/Complete | Components: | CDR/cdr_pgsql |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) cdr_pgsql.patch | |
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); | ||
Comments: | By: Digium Subversion (svnbot) 2007-07-27 11:46:54 Repository: asterisk Revision: 77540 ------------------------------------------------------------------------ r77540 | file | 2007-07-27 11:46:53 -0500 (Fri, 27 Jul 2007) | 6 lines (closes issue ASTERISK-9964) 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. ------------------------------------------------------------------------ By: Digium Subversion (svnbot) 2007-07-27 11:48:06 Repository: asterisk Revision: 77541 ------------------------------------------------------------------------ r77541 | file | 2007-07-27 11:48:05 -0500 (Fri, 27 Jul 2007) | 14 lines Merged revisions 77540 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r77540 | file | 2007-07-27 14:04:08 -0300 (Fri, 27 Jul 2007) | 6 lines (closes issue ASTERISK-9964) 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. ........ ------------------------------------------------------------------------ |