You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jc...@apache.org on 2017/06/20 23:34:18 UTC

svn commit: r1799376 - in /httpd/httpd/branches/httpdunit: include/httpd.h server/util.c test/unit/base64.c

Author: jchampion
Date: Tue Jun 20 23:34:18 2017
New Revision: 1799376

URL: http://svn.apache.org/viewvc?rev=1799376&view=rev
Log:
Revert new base64 function and tests

This should be trunk-only, not part of the backport branch.

Removed:
    httpd/httpd/branches/httpdunit/test/unit/base64.c
Modified:
    httpd/httpd/branches/httpdunit/include/httpd.h
    httpd/httpd/branches/httpdunit/server/util.c

Modified: httpd/httpd/branches/httpdunit/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpdunit/include/httpd.h?rev=1799376&r1=1799375&r2=1799376&view=diff
==============================================================================
--- httpd/httpd/branches/httpdunit/include/httpd.h (original)
+++ httpd/httpd/branches/httpdunit/include/httpd.h Tue Jun 20 23:34:18 2017
@@ -1998,28 +1998,6 @@ AP_DECLARE(const char *) ap_stripprefix(
 AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded);
 
 /**
- * Decode a base64 encoded string into memory allocated from a pool, while
- * ensuring that the input string is in fact valid base64.
- *
- * Unlike ap_pbase64decode(), this function allows encoded NULLs in the input to
- * be retained by the caller, by inspecting the len argument after the call
- * instead of using strlen(). A NULL terminator is still appended to the buffer
- * to faciliate string use (it is not included in len).
- *
- * @param p The pool to allocate from
- * @param encoded The encoded string
- * @param decoded On success, set to the decoded buffer, which is allocated from
- *                p
- * @param len On success, set to the length of the decoded buffer (not including
- *            the terminating NULL byte)
- * @return APR_SUCCESS if the decoding was successful
- */
-AP_DECLARE(apr_status_t) ap_pbase64decode_strict(apr_pool_t *p,
-                                                 const char *encoded,
-                                                 char **decoded,
-                                                 apr_size_t *len);
-
-/**
  * Encode a string into memory allocated from a pool in base 64 format
  * @param p The pool to allocate from
  * @param string The plaintext string

Modified: httpd/httpd/branches/httpdunit/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpdunit/server/util.c?rev=1799376&r1=1799375&r2=1799376&view=diff
==============================================================================
--- httpd/httpd/branches/httpdunit/server/util.c (original)
+++ httpd/httpd/branches/httpdunit/server/util.c Tue Jun 20 23:34:18 2017
@@ -2388,76 +2388,6 @@ AP_DECLARE(char *) ap_pbase64decode(apr_
     return decoded;
 }
 
-/* a stringent version of ap_pbase64decode() */
-AP_DECLARE(apr_status_t) ap_pbase64decode_strict(apr_pool_t *p,
-                                                 const char *encoded,
-                                                 char **decoded,
-                                                 apr_size_t *len)
-{
-    apr_size_t end_index;
-    int last_group_len;
-    const char *end;
-
-    /* Sanity check.
-     * TODO: this would be a lot more efficient if we had access to the lookup
-     * table used by APR. If that gets pulled in at any point, make use of it.
-     */
-    end_index = strspn(encoded, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                "abcdefghijklmnopqrstuvwxyz"
-                                "0123456789+/");
-
-    last_group_len = end_index % 4;
-    end = encoded + end_index;
-
-    /* The only non-alphabet character allowed is the padding character '=' at
-     * the end of the string. There are two allowable padding cases for the last
-     * group of four: "xY==" or "xyZ=". We require the final (non-padding)
-     * character to have been zero-padded during encoding, which limits the
-     * character choices.
-     */
-    if (last_group_len == 1) {
-        /* This isn't ever valid. */
-        return APR_EINVAL;
-    }
-    else if (last_group_len == 2) {
-        /* ...xY== */
-        if (*end != '=' || end[1] != '=') {
-            return APR_EINVAL;
-        }
-        else if (!ap_strchr("AQgw", end[-1])) {
-            /* Correctly zero-padded input data will result in a final character
-             * that is one of the four above. */
-            return APR_EINVAL;
-        }
-
-        end += 2;
-    }
-    else if (last_group_len == 3) {
-        /* ...xyZ= */
-        if (*end != '=') {
-            return APR_EINVAL;
-        }
-        else if (!ap_strchr("AEIMQUYcgkosw048", end[-1])) {
-            /* Correctly zero-padded input data will result in a final character
-             * that is one of the sixteen above. */
-            return APR_EINVAL;
-        }
-
-        end++;
-    }
-
-    /* At this point, if the encoded buffer is correct, we should be at the end
-     * of the string. */
-    if (*end) {
-        return APR_EINVAL;
-    }
-
-    *decoded = apr_palloc(p, apr_base64_decode_len(encoded));
-    *len = apr_base64_decode(*decoded, encoded);
-
-    return APR_SUCCESS;
-}
-
 AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string)
 {
     char *encoded;