~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/lib/libc/src/base64.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "plbase64.h"
39
39
#include "prlog.h" /* For PR_NOT_REACHED */
40
40
#include "prmem.h" /* for malloc / PR_MALLOC */
41
 
 
42
 
#include <string.h> /* for strlen */
 
41
#include "plstr.h" /* for PL_strlen */
43
42
 
44
43
static unsigned char *base = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
45
44
 
151
150
{
152
151
    if( 0 == srclen )
153
152
    {
154
 
        size_t len = strlen(src);
155
 
        srclen = len;
156
 
        /* Detect truncation. */
157
 
        if( srclen != len )
158
 
        {
159
 
            return (char *)0;
160
 
        }
 
153
        srclen = PL_strlen(src);
161
154
    }
162
155
 
163
156
    if( (char *)0 == dest )
396
389
 
397
390
    if( 0 == srclen )
398
391
    {
399
 
        size_t len = strlen(src);
400
 
        srclen = len;
401
 
        /* Detect truncation. */
402
 
        if( srclen != len )
403
 
        {
404
 
            return (char *)0;
405
 
        }
 
392
        srclen = PL_strlen(src);
406
393
    }
407
394
 
408
395
    if( srclen && (0 == (srclen & 3)) )
423
410
    if( (char *)0 == dest )
424
411
    {
425
412
        /* The following computes ((srclen * 3) / 4) without overflow. */
426
 
        PRUint32 destlen = (srclen / 4) * 3 + ((srclen % 4) * 3) / 4;
 
413
        PRUint32 rem = srclen % 4;
 
414
        PRUint32 destlen = (srclen / 4) * 3 + (rem * 3) / 4;
427
415
        dest = (char *)PR_MALLOC(destlen + 1);
428
416
        if( (char *)0 == dest )
429
417
        {