mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Fixed off-by-one error in rle-decode, and allow whitespace in base64
ascii input (thanks to Donald Beaudry for pointing these out)
This commit is contained in:
parent
61f3df4543
commit
ba1de3bafb
1 changed files with 5 additions and 5 deletions
|
@ -343,11 +343,11 @@ binascii_a2b_base64(self, args)
|
||||||
bin_data = (unsigned char *)PyString_AsString(rv);
|
bin_data = (unsigned char *)PyString_AsString(rv);
|
||||||
bin_len = 0;
|
bin_len = 0;
|
||||||
for( ; ascii_len > 0 ; ascii_len--, ascii_data++ ) {
|
for( ; ascii_len > 0 ; ascii_len--, ascii_data++ ) {
|
||||||
/*
|
/* Skip some punctuation */
|
||||||
** XXXX I don't do any checks on the chars, ignoring
|
|
||||||
** any illegal chars. Hope this is correct...
|
|
||||||
*/
|
|
||||||
this_ch = (*ascii_data & 0x7f);
|
this_ch = (*ascii_data & 0x7f);
|
||||||
|
if ( this_ch == '\r' || this_ch == '\n' || this_ch == ' ' )
|
||||||
|
continue;
|
||||||
|
|
||||||
if ( this_ch == BASE64_PAD )
|
if ( this_ch == BASE64_PAD )
|
||||||
npad++;
|
npad++;
|
||||||
this_ch = table_a2b_base64[(*ascii_data) & 0x7f];
|
this_ch = table_a2b_base64[(*ascii_data) & 0x7f];
|
||||||
|
@ -626,7 +626,7 @@ binascii_rledecode_hqx(self, args)
|
||||||
_PyString_Resize(&rv, 2*out_len); \
|
_PyString_Resize(&rv, 2*out_len); \
|
||||||
if ( rv == NULL ) return NULL; \
|
if ( rv == NULL ) return NULL; \
|
||||||
out_data = (unsigned char *)PyString_AsString(rv) + out_len; \
|
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_len = out_len * 2; \
|
||||||
} \
|
} \
|
||||||
*out_data++ = b; \
|
*out_data++ = b; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue