Author dev_zzo
Recipients JohnLeitch, dev_zzo, serhiy.storchaka
Date 2015-06-18.08:41:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1434616903.07.0.046706345216.issue24462@psf.upfronthosting.co.za>
In-reply-to
Content
From the author's page at http://effbot.org/zone/stringlib.htm

"Note that the above Python code may access s[n], which would result in an IndexError exception. For the CPython implementation, this is not really a problem, since CPython adds trailing NULL entries to both 8-bit and Unicode strings."

Apparently, this flaw was known to the author, but was not documented in C code.

A possible quick-and-dirty solution is to treat m=n as a special case and resort to memcmp() or somesuch as there is no actual need to perform multiple match tries. This should fix things for bytearray and str in case str's implementation changes from appending a trailing NUL.
History
Date User Action Args
2015-06-18 08:41:43dev_zzosetrecipients: + dev_zzo, serhiy.storchaka, JohnLeitch
2015-06-18 08:41:43dev_zzosetmessageid: <1434616903.07.0.046706345216.issue24462@psf.upfronthosting.co.za>
2015-06-18 08:41:43dev_zzolinkissue24462 messages
2015-06-18 08:41:42dev_zzocreate