summaryrefslogtreecommitdiff
path: root/epan/base64.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2008-03-16 09:54:00 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2008-03-16 09:54:00 +0000
commit9af351f536279fac053445369b5bb4e96e107416 (patch)
treeb558af15a261e04aa5055cc4ca84151d3097244e /epan/base64.c
parente2ee2bcab647a699c0d75899490fb0e937f905d9 (diff)
downloadwireshark-9af351f536279fac053445369b5bb4e96e107416.tar.gz
From Peter Kjellerstedt
The base64 decoder in epan_base64_decode() returns an incorrect length (one byte too many) for three out of four base64 coded strings. Please apply the attached patch to correct this. svn path=/trunk/; revision=24654
Diffstat (limited to 'epan/base64.c')
-rw-r--r--epan/base64.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/epan/base64.c b/epan/base64.c
index b390947f35..e48d941b1a 100644
--- a/epan/base64.c
+++ b/epan/base64.c
@@ -36,7 +36,7 @@
size_t epan_base64_decode(char *s)
{
static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\r\n";
- int bit_offset, byte_offset, idx, i, n;
+ int bit_offset, byte_offset, idx, i;
unsigned char *d = (unsigned char *)s;
char *p;
int cr_idx;
@@ -44,7 +44,7 @@ size_t epan_base64_decode(char *s)
/* we will allow CR and LF - but ignore them */
cr_idx = strchr(b64, '\r') - b64;
- n=i=0;
+ i=0;
while (*s && (p=strchr(b64, *s))) {
idx = (int)(p - b64);
@@ -54,17 +54,15 @@ size_t epan_base64_decode(char *s)
d[byte_offset] &= ~((1<<(8-bit_offset))-1);
if (bit_offset < 3) {
d[byte_offset] |= (idx << (2-bit_offset));
- n = byte_offset+1;
} else {
d[byte_offset] |= (idx >> (bit_offset-2));
d[byte_offset+1] = 0;
d[byte_offset+1] |= (idx << (8-(bit_offset-2))) & 0xFF;
- n = byte_offset+2;
}
i++;
}
s++;
}
- return n;
+ return i*3/4;
}