summaryrefslogtreecommitdiffstats
path: root/Modules/binascii.c
Commit message (Collapse)AuthorAgeFilesLines
* Followup to #7703: a2b_hqx() didn't follow the new buffer API (neither in trunkAntoine Pitrou2010-01-161-3/+14
| | | | nor in py3k). Patch by Florent Xicluna as well as additional tests.
* Issue #7701: Fix crash in binascii.b2a_uu() in debug mode when given aAntoine Pitrou2010-01-151-1/+1
| | | | 1-byte argument. Patch by Victor Stinner.
* Issue #7703: Add support for the new buffer API to functions of theAntoine Pitrou2010-01-141-70/+189
| | | | | binascii module. Backported from py3k by Florent Xicluna, with some additional tests.
* Merge in release25-maint r60793:Gregory P. Smith2008-06-111-3/+39
| | | | | | Added checks for integer overflows, contributed by Google. Some are only available if asserts are left in the code, in cases where they can't be triggered from Python code.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-42/+42
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-42/+42
|
* On platforms without zlib, make this do the right thing and return the pythonGregory P. Smith2008-03-251-71/+58
| | | | | | | | 2.x signed value. Also, don't waste space on a table full of unsigned longs when all it needs are unsigned ints (incase anyone builds this without zlib on a 64-bit unix for some strange reason). tested by forcing it to compile this version on both 32-bit and 64-bit linux.
* Use a 32-bit unsigned int here, a long is not needed.Gregory P. Smith2008-03-251-2/+2
|
* Have the binascii module use zlib's optimized crc32() function when availableGregory P. Smith2008-03-241-0/+24
| | | | | to reduce our code size (1k data table and tiny bit of code). It falls back to its own without zlib.
* Add a test to make sure zlib.crc32 and binascii.crc32 return the same thing.Gregory P. Smith2008-03-181-1/+1
| | | | | Fix a buglet in binascii.crc32, the second optional argument could previously have a signedness mismatch with the C variable its going into.
* Backport checkin:Walter Dörwald2007-05-091-1/+1
| | | | | Fix a segfault when b"" was passed to b2a_qp() -- it was using strchr() instead of memchr().
* Patch #1185447: binascii.b2a_qp() now correctly quotes binary charactersGeorg Brandl2007-03-131-4/+8
| | | | | | with ASCII value less than 32. Also, it correctly quotes dots only if they occur on a single line, as opposed to the previous behavior of quoting dots if they are the second character of any line.
* Bug #1588217: don't parse "= " as a soft line break in binascii'sGeorg Brandl2006-11-161-2/+1
| | | | | a2b_qp() function, instead leave it in the string as quopri.decode() does.
* Make binascii.hexlify() use s# for its arguments instead of t# to actuallyBrett Cannon2006-06-081-1/+1
| | | | match its documentation stating it accepts any read-only buffer.
* Correct some value converting strangenesses.Georg Brandl2006-05-291-1/+1
|
* Use Py_ssize_t for arithmetic on Py_ssize_t's, instead of unsigned ints.Thomas Wouters2006-03-011-2/+2
|
* Fix brainfart.Thomas Wouters2006-03-011-1/+1
|
* Make Py_ssize_t-clean.Thomas Wouters2006-03-011-17/+18
|
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-2/+2
|
* Check return result from Py_InitModule*(). This API can fail.Neal Norwitz2006-01-191-0/+2
| | | | Probably should be backported.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-2/+3
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* Remove redunandant assertions from last checkin.Raymond Hettinger2004-09-061-9/+0
|
* SF #1022953: binascii.a2b_hqx("") raises SystemErrorRaymond Hettinger2004-09-061-5/+16
| | | | | | | | | | | | | Several functions adopted the strategy of altering a full lengthed string copy and resizing afterwards. That would fail if the initial string was short enough (0 or 1) to be interned. Interning precluded the subsequent resizing operation. The solution was to make sure the initial string was at least two characters long. Added tests to verify that all binascii functions do not crater when given an empty string argument.
* Switch arguments to memset (kudos to MSVC C4318 for finding that)Martin v. Löwis2004-07-271-2/+2
|
* Valgrind was reporting an uninitialized read for bad input.Neal Norwitz2004-06-061-1/+2
| | | | | | | | | This fixes the problem and the test passes. I'm not sure the test is really correct though. It seems like it would be better to raise an exception. I think that wasn't done for backwards compatability. Bugfix candidate.
* In order to fix SF bug # 824977, we replace calloc()/free() calls inBarry Warsaw2004-05-111-9/+16
| | | | | | | binascii_a2b_qp() and binascii_b2a_qp() with calls to PyMem_Malloc() and PyMem_Free(). These won't return NULL unless the allocations actually fail, so it won't trigger a bogus memory error on some platforms <cough>AIX</cough> when passed a length of zero.
* binascii_a2b_base64: Properly return an empty string if the input was allThomas Wouters2003-03-171-1/+8
| | | | | | | invalid, rather than returning a string of random garbage of the estimated result length. Closes SF patch #703471 by Hye-Shik Chang. Will backport to 2.2-maint (consider it done.)
* base64.decodestring('') should return '' instead of raising anBarry Warsaw2002-08-151-5/+2
| | | | | exception. The bug fix for SF #430849 wasn't quite right. This closes SF bug #595671. I'll backport this to Python 2.2.
* Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototypeMark Hammond2002-08-021-1/+1
| | | | | | for Py_Main(). Thanks to Kalle Svensson and Skip Montanaro for the patches.
* Another stab at SF 576327: zipfile when sizeof(long) == 8Tim Peters2002-07-021-100/+106
| | | | | | | | binascii_crc32(): The previous patch forced this to return the same result across platforms. This patch deals with that, on a 64-bit box, the *entry* value may have "unexpected" bits in the high four bytes. Bugfix candidate.
* Fix for SF bug #576327: zipfile when sizeof(long) == 8Tim Peters2002-07-021-1/+11
| | | | | | | | | | binascii_crc32(): Make this return a signed 4-byte result across platforms. The other way to make this platform-independent would be to make it return an unsigned unbounded int, but the evidence suggests other code out there treats it like a signed 4-byte int (e.g., existing code writing the result with struct.pack "l" format). Bugfix candidate.
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-20/+20
|
* SF bug #494738: binascii_b2a_base64 overwrites memory.Tim Peters2001-12-191-3/+5
| | | | | | | | binascii_b2a_base64(): We didn't allocate enough buffer space for very short inputs (e.g., a 1-byte input can produce a 5-byte output, but we only allocated 2 bytes). I expect that malloc overheads absorbed the overrun in practice, but computing a correct upper bound is a very simple change.
* Change the limit on the input size for b2a_base64 to what will fit inGuido van Rossum2001-10-301-1/+3
| | | | | | memory, rather than the standard's 57. This fixes SF bug #473009.
* Add various typecasts (back and forth from char * to unsigned char *)Greg Ward2001-10-041-5/+5
| | | | to make the SGI C compiler happier (bug #445960).
* Patch #462190, patch #464070: Support quoted printable in the binascii module.Martin v. Löwis2001-09-301-0/+296
| | | | Decode and encode underscores for header style encoding. Fixes bug #463996.
* This closes bug #430849 (internal error produced by binascii.a2b_base64)Peter Schneider-Kamp2001-06-071-0/+4
|
* Address a bug in the uuencode decoder, reported bu "donut" in SF bugGuido van Rossum2001-01-091-3/+3
| | | | #127718: '@' and '`' seem to be confused.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-16/+0
| | | | This should match the situation in the 1.6b1 tree.
* Fix new compiler warnings. Unused var in compile.c. Argsize mismatchesTim Peters2000-08-151-1/+1
| | | | | | in binascii.c (only on platforms with signed chars -- although Py_CHARMASK is documented as returning an int, it only does so on platforms with signed chars).
* binascii_unhexlify(): Better error message, courtesy effbot.Barry Warsaw2000-08-151-5/+5
|
* After a brief conversation and code review with TP, adding two veryBarry Warsaw2000-08-151-22/+126
| | | | | | | | | | | | | | commonly used functions to convert an arbitrary binary string into a hexadecimal digit representation and back again. These are often (and often differently) implemented in Python. Best to have one common fast implementation. Specifically, binascii_hexlify(): a.k.a. b2a_hex() to return the hex representation of binary data. binascii_unhexlify(): a.k.a. a2b_hex() to do the inverse conversion (hex digits to binary data). The argument must have an even length, and must contain only hex digits, otherwise a TypeError is raised.
* Use METH_VARARGS instead of numeric constant 1 in method def. tablesAndrew M. Kuchling2000-08-031-13/+20
|
* Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',Thomas Wouters2000-07-211-1/+1
| | | | | | | | | | | | | | | | | | and a couple of functions that were missed in the previous batches. Not terribly tested, but very carefully scrutinized, three times. All these were found by the little findkrc.py that I posted to python-dev, which means there might be more lurking. Cases such as this: long func(a, b) long a; long b; /* flagword */ { and other cases where the last ; in the argument list isn't followed by a newline and an opening curly bracket. Regexps to catch all are welcome, of course ;)
* ANSI-ficationPeter Schneider-Kamp2000-07-101-34/+11
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Massive patch by Skip Montanaro to add ":name" to as manyGuido van Rossum2000-02-291-10/+10
| | | | PyArg_ParseTuple() format string arguments as possible.
* Patch by Jim Ahlstrom to add crc32, a useful checksum functionGuido van Rossum2000-02-161-0/+141
| | | | | | | | | | | (e.g. used for ZIP files). The patch includes code that says: + Copyright (C) 1986 Gary S. Brown. You may use this program, or + code or tables extracted from it, as desired without restriction. My interpretation (and Jim's) is that Gary S Brown has no claims under copyright, patent or other rights or interests. Lawyers might disagree.
* Patch by Jason Trowbridge. (Followup to his PR#110.) (SlightlyGuido van Rossum1999-10-191-18/+69
| | | | | | | | | | | | reformatted.) - Illegal padding is now ignored. (Recommendation by GvR.) - Padding no longer removes characters from data string (resulting in lost data/strings with negative lengths). - Illegal characters outside the ASCII range are now ignored, instead of possibly being remapped to a valid character.
* Fix PR#110 -- bad input ("====") for a2b_base64() caused it to callGuido van Rossum1999-10-191-0/+2
| | | | _PyString_Resize() with a negative size.