summaryrefslogtreecommitdiffstats
path: root/Modules/binascii.c
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-01-22 10:47:15 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-01-22 10:47:15 (GMT)
commitba1de3bafb4721f63ab6d8192b567a4008e22b65 (patch)
tree4eecf8e38ed5beae5128315f164c5f7d3e32eb33 /Modules/binascii.c
parent61f3df4543751f98d02c86b03aa97b72bc80992f (diff)
downloadcpython-ba1de3bafb4721f63ab6d8192b567a4008e22b65.zip
cpython-ba1de3bafb4721f63ab6d8192b567a4008e22b65.tar.gz
cpython-ba1de3bafb4721f63ab6d8192b567a4008e22b65.tar.bz2
Fixed off-by-one error in rle-decode, and allow whitespace in base64
ascii input (thanks to Donald Beaudry for pointing these out)
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r--Modules/binascii.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 8d47840..95d7bb0 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -343,11 +343,11 @@ binascii_a2b_base64(self, args)
bin_data = (unsigned char *)PyString_AsString(rv);
bin_len = 0;
for( ; ascii_len > 0 ; ascii_len--, ascii_data++ ) {
- /*
- ** XXXX I don't do any checks on the chars, ignoring
- ** any illegal chars. Hope this is correct...
- */
+ /* Skip some punctuation */
this_ch = (*ascii_data & 0x7f);
+ if ( this_ch == '\r' || this_ch == '\n' || this_ch == ' ' )
+ continue;
+
if ( this_ch == BASE64_PAD )
npad++;
this_ch = table_a2b_base64[(*ascii_data) & 0x7f];
@@ -626,7 +626,7 @@ binascii_rledecode_hqx(self, args)
_PyString_Resize(&rv, 2*out_len); \
if ( rv == NULL ) return NULL; \
out_data = (unsigned char *)PyString_AsString(rv) + out_len; \
- out_len_left = out_len; \
+ out_len_left = out_len-1; \
out_len = out_len * 2; \
} \
*out_data++ = b; \