[Python-bugs-list] [ python-Bugs-473009 ] binascii_b2a_base64() improper str limit (original) (raw)

noreply@sourceforge.net noreply@sourceforge.net
Fri, 19 Oct 2001 21:42:30 -0700


Bugs item #473009, was opened at 2001-10-19 21:42 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=473009&group_id=5470

Category: Python Library Group: Python 2.1.1 Status: Open Resolution: None Priority: 5 Submitted By: Dave Cinege (dcinege) Assigned to: Nobody/Anonymous (nobody) Summary: binascii_b2a_base64() improper str limit

Initial Comment: Modules/binascii.c binascii_b2a_base64() contains the following restrictive code: if ( bin_len > BASE64_MAXBIN ) { PyErr_SetString(Error, "Too much data for base64 line"); return NULL; }

This is an error. The base64 method of encoding data has no length limitation. The MIME message RCF has such a limitation of base64 encoded data. The function should not assume it's only input must be MIME compatible. The base64 python module itself is designed for MIME I/O only, and properly limits itself. The binascii function should be left raw.

binascii_a2b_base64() properly accepts input of any size.

How I came across this bug: I use base64 to ascii armor binary data in log entries in a distributed network monitoring system. For the sake of ease of parsing (human and machine) all log entries are delimited by a single line. I commonly have unbroken base64 encoded fields of 64KB in size or greater.

Unfortunatly I am unable to encode this data like this: result64 = binascii.b2a_base64(s) I must do this: result64 = re.sub('[ |\n]','',base64.encodestring(s)) Which is much slower. : <

I feel this is an outright bug and should be corrected. If their is some argument for backward compatibly an optional function argument should be present to allow bypassing this limitation.


You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=473009&group_id=5470