From 7fd36b79ebaff8821b3786725510b0d428631a0a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 27 Aug 2005 01:42:20 +0000 Subject: r9671: patch from Kai Blin fixing a bug in our base64 encoder (This used to be commit efa143cb3b4815fed7b037e05d591eadb828536b) --- source4/lib/ldb/common/ldb_ldif.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 6359c9a014..38866d7031 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -155,10 +155,10 @@ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len) const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset, byte_offset, idx, i; const uint8_t *d = (const uint8_t *)buf; - int bytes = (len*8 + 5)/6; + int bytes = (len*8 + 5)/6, pad_bytes = (bytes % 4) ? 4 - (bytes % 4) : 0; char *out; - out = talloc_array(mem_ctx, char, bytes+2); + out = talloc_array(mem_ctx, char, bytes+pad_bytes+1); if (!out) return NULL; for (i=0;i