diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-07 09:51:08 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-07 09:51:08 -0400 |
commit | 1e54bdd48a5deec7c1c4a0a167fb5abe312c8458 (patch) | |
tree | 5583af72976a2e70608974ba374345d4994bc38f | |
parent | 2c86380bdec15272652607025a6fb46eb54aeef8 (diff) | |
download | tor-1e54bdd48a5deec7c1c4a0a167fb5abe312c8458.tar.gz tor-1e54bdd48a5deec7c1c4a0a167fb5abe312c8458.zip |
Make the warnings about terminating nuls a bit stronger
It looks like 32_encoded_size/64_encode_size APIs are inconsistent
not only in the number of "d"s they have, but also in whether they
count the terminating NUL. Taylor noted this in 86477f4e3fedb316,
but I think we should note the inconsistently more loudly in order
to avoid trouble.
(I ran into trouble with this when writing 30b13fd82e243713c6a0d.)
-rw-r--r-- | src/common/util_format.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/common/util_format.c b/src/common/util_format.c index 80844af5b3..f6788e9687 100644 --- a/src/common/util_format.c +++ b/src/common/util_format.c @@ -22,8 +22,10 @@ #include <stdlib.h> /* Return the base32 encoded size in bytes using the source length srclen. - * The NUL terminated byte is added as well since every base32 encoding - * requires enough space for it. */ + * + * (WATCH OUT: This API counts the terminating NUL byte, but + * base64_encode_size does not.) + */ size_t base32_encoded_size(size_t srclen) { @@ -133,7 +135,8 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen) /** Return the Base64 encoded size of <b>srclen</b> bytes of data in * bytes. * - * Does <b>NOT</b> count the terminating NUL. + * (WATCH OUT: This API <em>does not</em> count the terminating NUL byte, + * but base64_encoded_size does.) * * If <b>flags</b>&BASE64_ENCODE_MULTILINE is true, return the size * of the encoded output as multiline output (64 character, `\n' terminated |