[tor-commits] [tor/master] Remove base64_decode_nopad()

nickm at torproject.org nickm at torproject.org
Mon Apr 10 15:29:58 UTC 2017


commit 2b38bb28b470dbca322ae64b7c5eaef9cd7206fa
Author: Taylor Yu <catalyst at torproject.org>
Date:   Fri Apr 7 17:54:50 2017 -0400

    Remove base64_decode_nopad()
    
    Remove base64_decode_nopad() because it is redundant now that
    base64_decode() correctly handles both padded and unpadded base64
    encodings with "right-sized" output buffers.
---
 src/common/util_format.c | 33 ---------------------------------
 src/common/util_format.h |  2 --
 2 files changed, 35 deletions(-)

diff --git a/src/common/util_format.c b/src/common/util_format.c
index 1033d14..1f7b8b0 100644
--- a/src/common/util_format.c
+++ b/src/common/util_format.c
@@ -313,39 +313,6 @@ base64_encode_nopad(char *dest, size_t destlen,
   return (int)(out - dest);
 }
 
-/** As base64_decode, but do not require any padding on the input */
-int
-base64_decode_nopad(uint8_t *dest, size_t destlen,
-                    const char *src, size_t srclen)
-{
-  if (srclen > SIZE_T_CEILING - 4)
-    return -1;
-  char *buf = tor_malloc(srclen + 4);
-  memcpy(buf, src, srclen+1);
-  size_t buflen;
-  switch (srclen % 4)
-    {
-    case 0:
-    default:
-      buflen = srclen;
-      break;
-    case 1:
-      tor_free(buf);
-      return -1;
-    case 2:
-      memcpy(buf+srclen, "==", 3);
-      buflen = srclen + 2;
-      break;
-    case 3:
-      memcpy(buf+srclen, "=", 2);
-      buflen = srclen + 1;
-      break;
-  }
-  int n = base64_decode((char*)dest, destlen, buf, buflen);
-  tor_free(buf);
-  return n;
-}
-
 #undef BASE64_OPENSSL_LINELEN
 
 /** @{ */
diff --git a/src/common/util_format.h b/src/common/util_format.h
index c928052..adf48c0 100644
--- a/src/common/util_format.h
+++ b/src/common/util_format.h
@@ -37,8 +37,6 @@ int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen,
 int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen);
 int base64_encode_nopad(char *dest, size_t destlen,
                         const uint8_t *src, size_t srclen);
-int base64_decode_nopad(uint8_t *dest, size_t destlen,
-                        const char *src, size_t srclen);
 
 /** Characters that can appear (case-insensitively) in a base32 encoding. */
 #define BASE32_CHARS "abcdefghijklmnopqrstuvwxyz234567"





More information about the tor-commits mailing list