From eba24bb920339038b473e8714690080009cb0d3a Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 19 Oct 1999 04:47:13 +0000 Subject: [PATCH] Fix PR#110 -- bad input ("====") for a2b_base64() caused it to call _PyString_Resize() with a negative size. --- Modules/binascii.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/binascii.c b/Modules/binascii.c index 73dc27a894..601169cfe3 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -384,6 +384,8 @@ binascii_a2b_base64(self, args) } /* and remove any padding */ bin_len -= npad; + if (bin_len < 0) + bin_len = 0; /* and set string size correctly */ _PyString_Resize(&rv, bin_len); return rv; -- 2.40.0