Changeset 2238:6390b65b36b6 for base64.c

Show
Ignore:
Timestamp:
2001-01-08 08:57:20 (8 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Fix and/or check more fishy code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • base64.c

    r1627 r2238  
    4646 
    4747/* raw bytes to null-terminated base 64 string */ 
    48 void mutt_to_base64 (unsigned char *out, const unsigned char *in, int len) 
     48void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len, 
     49                     size_t olen) 
    4950{ 
    50   while (len >= 3) 
     51  while (len >= 3 && olen > 10) 
    5152  { 
    5253    *out++ = B64Chars[in[0] >> 2]; 
     
    5455    *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; 
    5556    *out++ = B64Chars[in[2] & 0x3f]; 
    56     len -= 3; 
    57     in += 3; 
     57    olen  -= 4; 
     58    len   -= 3; 
     59    in    += 3; 
    5860  } 
    5961 
    6062  /* clean up remainder */ 
    61   if (len > 0) 
     63  if (len > 0 && olen > 4) 
    6264  { 
    6365    unsigned char fragment;