From a6ff061087eaf644eb30f0e8334059c5cbb0dbc1 Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 15 Nov 2018 22:31:39 +0000 Subject: [PATCH 1592/1800] 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 bb918f27f..571eb07b1 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 { -- 2.19.1