Module: wine Branch: master Commit: 050a46f30f42043601166e8aa435c6b97d6137cd URL: http://source.winehq.org/git/wine.git/?a=commit;h=050a46f30f42043601166e8aa4...
Author: Hans Leidekker hans@codeweavers.com Date: Wed Sep 4 15:00:35 2013 +0200
winhttp: Fix the base64 decoder.
---
dlls/winhttp/request.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 35a0deb..db8e6af 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1384,7 +1384,7 @@ static unsigned int decode_base64( const WCHAR *base64, unsigned int len, char * char c0, c1, c2, c3; const WCHAR *p = base64;
- while (len >= 4) + while (len > 4) { if ((c0 = decode_char( p[0] )) > 63) return 0; if ((c1 = decode_char( p[1] )) > 63) return 0; @@ -1422,6 +1422,21 @@ static unsigned int decode_base64( const WCHAR *base64, unsigned int len, char * } i += 2; } + else + { + if ((c0 = decode_char( p[0] )) > 63) return 0; + if ((c1 = decode_char( p[1] )) > 63) return 0; + if ((c2 = decode_char( p[2] )) > 63) return 0; + if ((c3 = decode_char( p[3] )) > 63) return 0; + + if (buf) + { + buf[i + 0] = (c0 << 2) | (c1 >> 4); + buf[i + 1] = (c1 << 4) | (c2 >> 2); + buf[i + 2] = (c2 << 6) | c3; + } + i += 3; + } return i; }