projects
/
haproxy-2.3.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
32d75ed
)
BUG/MINOR: base64: dec func ignores padding for output size checking
author
Emeric Brun
<ebrun@haproxy.com>
Mon, 14 Jan 2019 13:38:39 +0000
(14:38 +0100)
committer
Willy Tarreau
<w@1wt.eu>
Mon, 14 Jan 2019 18:32:15 +0000
(19:32 +0100)
Decode function returns an error even if the ouptut buffer is
large enought because the padding was not considered. This
case was never met with current code base.
src/base64.c
patch
|
blob
|
history
diff --git
a/src/base64.c
b/src/base64.c
index
f7961c5
..
e7c9519
100644
(file)
--- a/
src/base64.c
+++ b/
src/base64.c
@@
-83,7
+83,9
@@
int base64dec(const char *in, size_t ilen, char *out, size_t olen) {
if (ilen % 4)
return -1;
- if (olen < ilen / 4 * 3)
+ if (olen < ((ilen / 4 * 3)
+ - (in[ilen-1] == '=' ? 1 : 0)
+ - (in[ilen-2] == '=' ? 1 : 0)))
return -2;
while (ilen) {