diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-09-01 06:01:19 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-09-01 06:01:19 +0000 |
commit | 296038d49800c8657e7cf718f308541630748e7f (patch) | |
tree | 604e95ec64ffdb697b8429063460f5dfded57094 /source3 | |
parent | a5f8955ccb875f8467a83c241abf2e58c2bb96f4 (diff) | |
download | samba-296038d49800c8657e7cf718f308541630748e7f.tar.gz samba-296038d49800c8657e7cf718f308541630748e7f.tar.bz2 samba-296038d49800c8657e7cf718f308541630748e7f.zip |
fixed a bug in the base64 hanlding that led to auth failures for some
passwords with SWAT
(This used to be commit edcde70108ab643a29f3e0e0cc97609287da6e87)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/web/cgi.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source3/web/cgi.c b/source3/web/cgi.c index 20337e0459..ce1038231b 100644 --- a/source3/web/cgi.c +++ b/source3/web/cgi.c @@ -431,11 +431,11 @@ decode a base64 string in-place - simple and slow algorithm static void base64_decode(char *s) { char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - int bit_offset, byte_offset, idx, i; + int bit_offset, byte_offset, idx, i, n; unsigned char *d = (unsigned char *)s; char *p; - i=0; + n=i=0; while (*s && (p=strchr(b64,*s))) { idx = (int)(p - b64); @@ -444,13 +444,17 @@ static void 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; } s++; i++; } + /* null terminate */ + d[n] = 0; } |