[asterisk-commits] mmichelson: branch 12 r416442 - /branches/12/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 17 11:33:16 CDT 2014


Author: mmichelson
Date: Tue Jun 17 11:33:13 2014
New Revision: 416442

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416442
Log:
Fix string growth algorithm for XML presence bodies.

pjpidf_print() does not return < 0 if there is not enough
room for the document to be printed. Rather, it returns
39, the length of the XML prolog.

The algorithm also had a bug in that it would return if
it attempted to grow the string larger.


Modified:
    branches/12/res/res_pjsip_pidf_body_generator.c
    branches/12/res/res_pjsip_xpidf_body_generator.c

Modified: branches/12/res/res_pjsip_pidf_body_generator.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_pidf_body_generator.c?view=diff&rev=416442&r1=416441&r2=416442
==============================================================================
--- branches/12/res/res_pjsip_pidf_body_generator.c (original)
+++ branches/12/res/res_pjsip_pidf_body_generator.c Tue Jun 17 11:33:13 2014
@@ -80,6 +80,7 @@
 }
 
 #define MAX_STRING_GROWTHS 3
+#define XML_PROLOG 39
 
 static void pidf_to_string(void *body, struct ast_str **str)
 {
@@ -89,14 +90,13 @@
 
 	do {
 		size = pjpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str) - 1);
-		if (size < 0) {
+		if (size == XML_PROLOG) {
 			ast_str_make_space(str, ast_str_size(*str) * 2);
 			++growths;
-			return;
 		}
-	} while (size < 0 && growths < MAX_STRING_GROWTHS);
+	} while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
 
-	if (size < 0) {
+	if (size == XML_PROLOG) {
 		ast_log(LOG_WARNING, "PIDF body text too large\n");
 		return;
 	}

Modified: branches/12/res/res_pjsip_xpidf_body_generator.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_xpidf_body_generator.c?view=diff&rev=416442&r1=416441&r2=416442
==============================================================================
--- branches/12/res/res_pjsip_xpidf_body_generator.c (original)
+++ branches/12/res/res_pjsip_xpidf_body_generator.c Tue Jun 17 11:33:13 2014
@@ -97,6 +97,7 @@
 }
 
 #define MAX_STRING_GROWTHS 3
+#define XML_PROLOG 39
 
 static void xpidf_to_string(void *body, struct ast_str **str)
 {
@@ -105,16 +106,14 @@
 	int size;
 
 	do {
-
 		size = pjxpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str));
-		if (size < 0) {
+		if (size == XML_PROLOG) {
 			ast_str_make_space(str, ast_str_size(*str) * 2);
 			++growths;
-			return;
 		}
-	} while (size < 0 && growths < MAX_STRING_GROWTHS);
+	} while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
 
-	if (size < 0) {
+	if (size == XML_PROLOG) {
 		ast_log(LOG_WARNING, "XPIDF body text too large\n");
 		return;
 	}




More information about the asterisk-commits mailing list