[asterisk-commits] russell: trunk r335511 - in /trunk: ./ include/asterisk/ main/ res/ais/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 13 02:36:02 CDT 2011


Author: russell
Date: Tue Sep 13 02:35:59 2011
New Revision: 335511

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=335511
Log:
Merged revisions 335510 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r335510 | russell | 2011-09-13 02:24:34 -0500 (Tue, 13 Sep 2011) | 22 lines
  
  Merged revisions 335497 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r335497 | russell | 2011-09-13 02:11:36 -0500 (Tue, 13 Sep 2011) | 15 lines
    
    Fix a crash in res_ais.
    
    This patch resolves a crash observed in a load testing environment that
    involved the use of the res_ais module.  I observed some crashes where
    the event delivery callback would get called, but the length parameter
    incidcating how much data there was to read was 0.  The code assumed
    (with good reason I would think) that if this callback got called, there
    was an event available to read.  However, if the rare case that there's
    nothing there, catch it and return instead of blowing up.
    
    More specifically, the change always ensure that the size of the received
    event in the cluster is always big enough to be a real ast_event.
    
    Review: https://reviewboard.asterisk.org/r/1423/
  ........
................

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/event.h
    trunk/main/event.c
    trunk/res/ais/evt.c

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

Modified: trunk/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/event.h?view=diff&rev=335511&r1=335510&r2=335511
==============================================================================
--- trunk/include/asterisk/event.h (original)
+++ trunk/include/asterisk/event.h Tue Sep 13 02:35:59 2011
@@ -743,6 +743,13 @@
  */
 uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator);
 
+/*!
+ * \brief Get the minimum length of an ast_event.
+ *
+ * \return minimum amount of memory that will be consumed by any ast_event.
+ */
+size_t ast_event_minimum_length(void);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: trunk/main/event.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/event.c?view=diff&rev=335511&r1=335510&r2=335511
==============================================================================
--- trunk/main/event.c (original)
+++ trunk/main/event.c Tue Sep 13 02:35:59 2011
@@ -1769,3 +1769,8 @@
 
 	return 0;
 }
+
+size_t ast_event_minimum_length(void)
+{
+	return sizeof(struct ast_event);
+}

Modified: trunk/res/ais/evt.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ais/evt.c?view=diff&rev=335511&r1=335510&r2=335511
==============================================================================
--- trunk/res/ais/evt.c (original)
+++ trunk/res/ais/evt.c Tue Sep 13 02:35:59 2011
@@ -132,6 +132,13 @@
 		ast_log(LOG_ERROR, "Event received with size %u, which is too big\n"
 			"for the allocated size %u. Change the code to increase the size.\n",
 			(unsigned int) event_datalen, (unsigned int) len);
+		return;
+	}
+
+	if (event_datalen < ast_event_minimum_length()) {
+		ast_debug(1, "Ignoring event that's too small. %u < %u\n",
+			(unsigned int) event_datalen,
+			(unsigned int) ast_event_minimum_length());
 		return;
 	}
 




More information about the asterisk-commits mailing list