[asterisk-commits] mnicholson: branch 1.6.2 r228649 - in /branches/1.6.2: ./ funcs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 6 14:26:24 CST 2009


Author: mnicholson
Date: Fri Nov  6 14:26:17 2009
New Revision: 228649

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=228649
Log:
Merged revisions 228620 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r228620 | mnicholson | 2009-11-06 13:47:11 -0600 (Fri, 06 Nov 2009) | 15 lines
  
  Merged revisions 228378 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r228378 | mnicholson | 2009-11-06 10:26:59 -0600 (Fri, 06 Nov 2009) | 8 lines
    
    Properly handle '=' while decoding base64 messages and null terminate strings returned from BASE64_DECODE.
    
    (closes issue #15271)
    Reported by: chappell
    Patches:
          base64_fix.patch uploaded by chappell (license 8)
    Tested by: kobaz
  ........
................

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/funcs/func_base64.c
    branches/1.6.2/main/utils.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/funcs/func_base64.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/funcs/func_base64.c?view=diff&rev=228649&r1=228648&r2=228649
==============================================================================
--- branches/1.6.2/funcs/func_base64.c (original)
+++ branches/1.6.2/funcs/func_base64.c Fri Nov  6 14:26:17 2009
@@ -75,12 +75,19 @@
 static int base64_decode(struct ast_channel *chan, const char *cmd, char *data,
 			 char *buf, size_t len)
 {
+	int decoded_len;
+
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");
 		return -1;
 	}
 
-	ast_base64decode((unsigned char *) buf, data, len);
+	decoded_len = ast_base64decode((unsigned char *) buf, data, len);
+	if (decoded_len <= (len - 1)) {		/* if not truncated, */
+		buf[decoded_len] = '\0';
+	} else {
+		buf[len - 1] = '\0';
+	}
 
 	return 0;
 }

Modified: branches/1.6.2/main/utils.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/utils.c?view=diff&rev=228649&r1=228648&r2=228649
==============================================================================
--- branches/1.6.2/main/utils.c (original)
+++ branches/1.6.2/main/utils.c Fri Nov  6 14:26:17 2009
@@ -267,7 +267,7 @@
 	unsigned int byte = 0;
 	unsigned int bits = 0;
 	int incnt = 0;
-	while (*src && (cnt < max)) {
+	while(*src && *src != '=' && (cnt < max)) {
 		/* Shift in 6 bits of input */
 		byte <<= 6;
 		byte |= (b2a[(int)(*src)]) & 0x3f;




More information about the asterisk-commits mailing list