summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-07-22 13:39:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:15 -0500
commit0c6d7f28d6c1066cc6b3055ebf6a8fcf685ca1f6 (patch)
treeaab81a105d51d7985421a12bb0496f35a4dc3a26 /source3/lib
parentd810ffe58e9c6b3b71336f59b899012af9137fe7 (diff)
downloadsamba-0c6d7f28d6c1066cc6b3055ebf6a8fcf685ca1f6.tar.gz
samba-0c6d7f28d6c1066cc6b3055ebf6a8fcf685ca1f6.tar.bz2
samba-0c6d7f28d6c1066cc6b3055ebf6a8fcf685ca1f6.zip
r1570: merging changes from 3.0.5
(This used to be commit 430cf63b9148441bce42bfb15a8045de5da108f4)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 7c5fa11c92..1083076edd 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1949,7 +1949,9 @@ DATA_BLOB base64_decode_data_blob(const char *s)
s++; i++;
}
- if (*s == '=') n -= 1;
+ if ((n > 0) && (*s == '=')) {
+ n -= 1;
+ }
/* fix up length */
decoded.length = n;
@@ -1962,9 +1964,15 @@ DATA_BLOB base64_decode_data_blob(const char *s)
void base64_decode_inplace(char *s)
{
DATA_BLOB decoded = base64_decode_data_blob(s);
- memcpy(s, decoded.data, decoded.length);
- /* null terminate */
- s[decoded.length] = '\0';
+
+ if ( decoded.length != 0 ) {
+ memcpy(s, decoded.data, decoded.length);
+
+ /* null terminate */
+ s[decoded.length] = '\0';
+ } else {
+ *s = '\0';
+ }
data_blob_free(&decoded);
}