[asterisk-commits] kmoore: trunk r374933 - in /trunk: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 12 16:58:32 CDT 2012


Author: kmoore
Date: Fri Oct 12 16:58:29 2012
New Revision: 374933

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374933
Log:
Avoid a segfault on invalid format names

If a format name was not found by ast_getformatbyname, a NULL pointer
would be passed into ast_format_rate and immediately dereferenced.
This ensures that a valid pointer is used since the structure is
already allocated on the stack.

(closes issue DPH-523)
Reported-by: Steve Pitts
........

Merged revisions 374932 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=374933&r1=374932&r2=374933
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Fri Oct 12 16:58:29 2012
@@ -6006,12 +6006,13 @@
 	if ((recording_fs = ast_readfile(recdata->recording_file, recdata->recording_ext, NULL, 0, 0, VOICEMAIL_DIR_MODE))) {
 		if (!ast_seekstream(recording_fs, 0, SEEK_END)) {
 			long framelength = ast_tellstream(recording_fs);
-			struct ast_format result;
+			struct ast_format result = {0,};
 			/* XXX This use of ast_getformatbyname seems incorrect here. The file extension does not necessarily correspond
 			 * to the name of the format. For instance, if "raw" were passed in, I don't think ast_getformatbyname would
 			 * find the slinear format
 			 */
-			duration = (int) (framelength / ast_format_rate(ast_getformatbyname(recdata->recording_ext, &result)));
+			ast_getformatbyname(recdata->recording_ext, &result);
+			duration = (int) (framelength / ast_format_rate(&result));
 		}
 	}
 




More information about the asterisk-commits mailing list