diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-27 01:42:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:34:38 -0500 |
commit | 7fd36b79ebaff8821b3786725510b0d428631a0a (patch) | |
tree | 7a857bfa091d3c115b7242b7a3292beed1c89e0b /source4/lib/ldb/common | |
parent | bcc288d880e4e76154da66c9eb4a8e25367bfc6c (diff) | |
download | samba-7fd36b79ebaff8821b3786725510b0d428631a0a.tar.gz samba-7fd36b79ebaff8821b3786725510b0d428631a0a.tar.bz2 samba-7fd36b79ebaff8821b3786725510b0d428631a0a.zip |
r9671: patch from Kai Blin fixing a bug in our base64 encoder
(This used to be commit efa143cb3b4815fed7b037e05d591eadb828536b)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_ldif.c | 7 |
1 files changed, 4 insertions, 3 deletions
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<bytes;i++) { @@ -175,7 +175,8 @@ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len) out[i] = b64[idx]; } - out[i++] = '='; + for (;i<bytes+pad_bytes;i++) + out[i] = '='; out[i] = 0; return out; |