git.samba.org
/
sfrench
/
samba-autobuild
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bcc288d
)
r9671: patch from Kai Blin fixing a bug in our base64 encoder
author
Andrew Tridgell
<tridge@samba.org>
Sat, 27 Aug 2005 01:42:20 +0000
(
01:42
+0000)
committer
Gerald (Jerry) Carter
<jerry@samba.org>
Wed, 10 Oct 2007 18:34:38 +0000
(13:34 -0500)
(This used to be commit
efa143cb3b4815fed7b037e05d591eadb828536b
)
source4/lib/ldb/common/ldb_ldif.c
patch
|
blob
|
history
diff --git
a/source4/lib/ldb/common/ldb_ldif.c
b/source4/lib/ldb/common/ldb_ldif.c
index 6359c9a01494e6b809f9599397696e2d6d1cc1d2..38866d703132af4b404dc53694650fcf56926048 100644
(file)
--- 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;
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;
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++) {
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] = b64[idx];
}
- out[i++] = '=';
+ for (;i<bytes+pad_bytes;i++)
+ out[i] = '=';
out[i] = 0;
return out;
out[i] = 0;
return out;