From d1e5b0f72f8fd4f57590893488e6fd2df7fba2d2 Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 15 Nov 2018 22:31:39 +0000 Subject: fixes segfault [00d04c4f12], unfulfilled base64 (strict and non-strict mode, etc). --- generic/tclBinary.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index bb918f2..571eb07 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2914,6 +2914,11 @@ BinaryDecode64( } else if (i > 1) { c = '='; } else { + if (strict && i <= 1) { + /* single resp. unfulfilled char (each 4th next single char) + * is rather bad64 error case in strict mode */ + goto bad64; + } cut += 3; break; } @@ -2944,9 +2949,11 @@ BinaryDecode64( value = (value << 6) | 0x3e; } else if (c == '/') { value = (value << 6) | 0x3f; - } else if (c == '=') { + } else if (c == '=' && ( + !strict || i > 1) /* "=" and "a=" is rather bad64 error case in strict mode */ + ) { value <<= 6; - cut++; + if (i) cut++; } else if (strict || !isspace(c)) { goto bad64; } else { -- cgit v0.12