git.samba.org
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9fee8c2
)
fixed a bug in the base64 hanlding that led to auth failures for some
author
Andrew Tridgell
<tridge@samba.org>
Tue, 1 Sep 1998 06:01:19 +0000
(06:01 +0000)
committer
Andrew Tridgell
<tridge@samba.org>
Tue, 1 Sep 1998 06:01:19 +0000
(06:01 +0000)
passwords with SWAT
source/web/cgi.c
patch
|
blob
|
history
diff --git
a/source/web/cgi.c
b/source/web/cgi.c
index 20337e04599778797abca28d9816890e0e2d814d..ce1038231b173bf746c01ca473fda7f898780e9d 100644
(file)
--- a/
source/web/cgi.c
+++ b/
source/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+/";
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;
unsigned char *d = (unsigned char *)s;
char *p;
- i=0;
+
n=
i=0;
while (*s && (p=strchr(b64,*s))) {
idx = (int)(p - b64);
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));
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;
} 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++;
}
}
s++; i++;
}
+ /* null terminate */
+ d[n] = 0;
}
}