[PHP-DEV] CVS update: php3/functions From: jim (php-dev <email protected>)
Date: 10/10/98

Date: Saturday October 10, 1998 @ 19:55
Author: jim

Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv20800

Modified Files:
        base64.c
Log Message:
Return correct length of decoded string.

Index: php3/functions/base64.c
diff -c php3/functions/base64.c:1.22 php3/functions/base64.c:1.23
*** php3/functions/base64.c:1.22 Mon Jun 1 03:07:02 1998
--- php3/functions/base64.c Sat Oct 10 19:55:41 1998
***************
*** 26,32 ****
     | Author: Jim Winstead (jimw <email protected>) |
     +----------------------------------------------------------------------+
   */
! /* $Id: base64.c,v 1.22 1998/06/01 07:07:02 rasmus Exp $ */
  
  #ifdef THREAD_SAFE
  #include "tls.h"
--- 26,32 ----
     | Author: Jim Winstead (jimw <email protected>) |
     +----------------------------------------------------------------------+
   */
! /* $Id: base64.c,v 1.23 1998/10/10 23:55:41 jim Exp $ */
  
  #ifdef THREAD_SAFE
  #include "tls.h"
***************
*** 85,91 ****
  /* as above, but backwards. :) */
  unsigned char *_php3_base64_decode(const unsigned char *string, int length, int *ret_length) {
          const unsigned char *current = string;
! int ch, i = 0, j = 0;
  
          unsigned char *result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char));
          if (result == NULL) {
--- 85,91 ----
  /* as above, but backwards. :) */
  unsigned char *_php3_base64_decode(const unsigned char *string, int length, int *ret_length) {
          const unsigned char *current = string;
! int ch, i = 0, j = 0, k;
  
          unsigned char *result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char));
          if (result == NULL) {
***************
*** 121,126 ****
--- 121,127 ----
                  i++;
          }
  
+ k = j;
          /* mop things up if we ended on a boundary */
          if (ch == base64_pad) {
                  switch(i % 4) {
***************
*** 129,143 ****
                          efree(result);
                          return NULL;
                  case 2:
! j++;
                  case 3:
! result[j++] = 0;
                  }
          }
          if(ret_length) {
                  *ret_length = j;
          }
! result[j] = '\0';
          return result;
  }
  
--- 130,144 ----
                          efree(result);
                          return NULL;
                  case 2:
! k++;
                  case 3:
! result[k++] = 0;
                  }
          }
          if(ret_length) {
                  *ret_length = j;
          }
! result[k] = '\0';
          return result;
  }
  

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>