Changeset 2238:6390b65b36b6 for base64.c
Legend:
- Unmodified
- Added
- Removed
-
base64.c
r1627 r2238 46 46 47 47 /* raw bytes to null-terminated base 64 string */ 48 void mutt_to_base64 (unsigned char *out, const unsigned char *in, int len) 48 void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len, 49 size_t olen) 49 50 { 50 while (len >= 3 )51 while (len >= 3 && olen > 10) 51 52 { 52 53 *out++ = B64Chars[in[0] >> 2]; … … 54 55 *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; 55 56 *out++ = B64Chars[in[2] & 0x3f]; 56 len -= 3; 57 in += 3; 57 olen -= 4; 58 len -= 3; 59 in += 3; 58 60 } 59 61 60 62 /* clean up remainder */ 61 if (len > 0 )63 if (len > 0 && olen > 4) 62 64 { 63 65 unsigned char fragment;
