summaryrefslogtreecommitdiff
path: root/encoding
Commit message (Collapse)AuthorAgeFilesLines
* apr_base64: Don't fault with assert() when NDEBUG is defined, abort() directly.Yann Ylavic2023-04-131-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | Per Evgeny: """ 1) The debug implementation of an assert() may print a diagnostic message, for example to stderr. A caller of the library function may not be ready for this to happen when using a non-debug version of the library. 2) The actual destination of the message seems to be implementation-defined. For example, in Windows-based applications this may show a message box [1], which is probably even more unexpected for the user of the library. 3) Undefining NDEBUG before other headers may silently cause unexpected effects if any of those headers make some decisions based on the NDEBUG value, which isn't an entirely unreasonable thing to expect. """ We want to always fault on failure though, so define and use our own APR__ASSERT() macro which calls abort() directly when NDEBUG is defined. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1909117 13f79535-47bb-0310-9956-ffa450edef68
* Remove trailing whitespaces in *.c.Ivan Zhakov2022-11-202-3/+3
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
* apr_base64: Follow up to r1902206: Cap to APR_BASE64_ENCODE_MAX in ↵Yann Ylavic2022-10-171-2/+2
| | | | | | apr_pbase64_encode(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1904666 13f79535-47bb-0310-9956-ffa450edef68
* more whitespaceEric Covener2022-06-281-28/+28
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902321 13f79535-47bb-0310-9956-ffa450edef68
* whitespace onlyEric Covener2022-06-281-16/+16
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902320 13f79535-47bb-0310-9956-ffa450edef68
* detabEric Covener2022-06-281-50/+50
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902319 13f79535-47bb-0310-9956-ffa450edef68
* encoding: Better check inputs of apr_{encode,decode}_* functions.Yann Ylavic2022-06-272-635/+769
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check that the given sources can be encoded without overflowing. Return APR_EINVAL if the given "slen" is negative, APR_NOTFOUND if "dest" is not NULL and "src" is NULL, or APR_ENOSPC if "dest" is NULL and the source length (based on "slen" or APR_ENCODE_STRING) is too big to encode. * include/private/apr_encode_private.h(): Rename ENCODE_TO_ASCII() and ENCODE_TO_NATIVE() to respectively TO_ASCII() and TO_ENCODE(), and make them return an unsigned char. * encoding/apr_escape.c(): Use the new TO_ASCII() and TO_NATIVE(). * encoding/apr_encode.c(apr_encode_*, apr_decode_*): Forbid negative "slen" but APR_ENCODE_STRING, and use apr_size_t arithmetics to check for overflows when encoding. When "dest" is NULL, "src" can be NULL too. Better check for trailing '='s or base16's APR_ENCODE_COLON ':' separators. Rename ENCODE_TO_ASCII and ENCODE_TO_NATIVE to their new names, and remove casts to (unsigned char) now unnecessary. * include/apr_encode.h(): Update dox about acceptable inputs and returned errors. * test/testencode.c(): Tests for error conditions. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902281 13f79535-47bb-0310-9956-ffa450edef68
* apr_base64: Make sure encoding/decoding lengths fit in an int >= 0.Yann Ylavic2022-06-231-18/+28
| | | | | | | | | | | | | | | | | | | | | | The (old) API of apr_base64 functions has always used int for representing lengths and it does not return errors. Make sure to abort() if the provided data don't fit. * encoding/apr_base64.c(): #define APR_BASE64_ENCODE_MAX and APR_BASE64_DECODE_MAX as the hard length limits for encoding and decoding respectively. * encoding/apr_base64.c(apr_base64_encode_len, apr_base64_encode, apr_base64_encode_binary, apr_pbase64_encode): abort() if the given length is above APR_BASE64_ENCODE_MAX. * encoding/apr_base64.c(apr_base64_decode_len, apr_base64_decode, apr_base64_decode_binary, apr_pbase64_decode): abort() if the given plain buffer length is above APR_BASE64_DECODE_MAX. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902206 13f79535-47bb-0310-9956-ffa450edef68
* apr_decode_base{64,32,16}: stop reading before (not including) NUL byte.Yann Ylavic2020-11-271-18/+42
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883870 13f79535-47bb-0310-9956-ffa450edef68
* apr_encode_base32: fix advertised output *len when called with dst == NULL.Yann Ylavic2020-11-271-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883868 13f79535-47bb-0310-9956-ffa450edef68
* apr_base64: avoid double NUL termination in apr_pbase64_{encode,decode}()Yann Ylavic2020-11-271-6/+3
| | | | | | | | | | | Since apr_base64_{encode,decode}() already NUL terminate the result, it needs not be done in apr_pbase64_{encode,decode}(). The NUL byte is also included in apr_base64_decode_len(), so no need to reserve an extra one in apr_pbase64_decode() etiher. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883861 13f79535-47bb-0310-9956-ffa450edef68
* Address some warnings raised by MSVC-32/64.Yann Ylavic2019-04-031-2/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1856873 13f79535-47bb-0310-9956-ffa450edef68
* Add the apr_encode_* API that implements RFC4648 and RFC7515Graham Leggett2018-06-252-44/+1423
| | | | | | | | compliant BASE64, BASE64URL, BASE32, BASE32HEX and BASE16 encode/decode functions. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834371 13f79535-47bb-0310-9956-ffa450edef68
* Correct spelling.Graham Leggett2018-06-111-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1833361 13f79535-47bb-0310-9956-ffa450edef68
* apr_base64_encode_len() already inclues the \0.Dirk-Willem van Gulik2017-01-241-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1780034 13f79535-47bb-0310-9956-ffa450edef68
* * Correctly calculate the size of the returned string and set the correctRuediger Pluem2014-11-271-0/+2
| | | | | | | | | | | | return value in case we actually escape the string. PR: 57230 Submitted by: <aduryagin gmail.com> Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1642159 13f79535-47bb-0310-9956-ffa450edef68
* Split the ability to filter LDAP escape sequences into DN escaping or filterGraham Leggett2014-04-211-6/+9
| | | | | | | escaping, allowing the option to escape both at the same time. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1588937 13f79535-47bb-0310-9956-ffa450edef68
* Add apr_escape_ldap() and apr_pescape_ldap(), escaping charactersGraham Leggett2014-04-211-0/+68
| | | | | | | as described by RFC4514 and RFC4515 respectively. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1588878 13f79535-47bb-0310-9956-ffa450edef68
* replace EBCDIC-only remnants of httpd / dependency on apr_xlate that made itEric Covener2013-12-211-7/+38
| | | | | | | | into the apr_escape implementation. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1552852 13f79535-47bb-0310-9956-ffa450edef68
* Remove non-portable escaping of the escape character in apr_escape_echo(). ↵Graham Leggett2013-10-091-6/+0
| | | | | | | | | Ensure test case runs correctly on Windows and OS/2. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1530786 13f79535-47bb-0310-9956-ffa450edef68
* Add apr_pbase64_encode() and apr_pbase64_decode() to encode to/fromGraham Leggett2013-06-061-0/+24
| | | | | | | the pool. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1490248 13f79535-47bb-0310-9956-ffa450edef68
* Add the apr_escape interface.Graham Leggett2013-06-041-0/+1156
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1489517 13f79535-47bb-0310-9956-ffa450edef68
* Correctly document the handling of trailing \0 charactersStefan Fritsch2010-09-101-2/+3
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@995861 13f79535-47bb-0310-9956-ffa450edef68
* Convert various APU_DECLARE into APR_DECLARE.Bojan Smojver2009-07-161-7/+7
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@794523 13f79535-47bb-0310-9956-ffa450edef68
* Merge APR-Util trunk into APR.Paul Querna2009-03-241-0/+268
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@757704 13f79535-47bb-0310-9956-ffa450edef68