aboutsummaryrefslogtreecommitdiff
path: root/src/lib/encoding
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-03-11 10:35:47 -0400
committerNick Mathewson <nickm@torproject.org>2020-03-11 10:35:47 -0400
commiteed196f122bc83d77a86a3d15659aac1201ed219 (patch)
tree766471ce8669b7e18c5d58f010b0711839194e98 /src/lib/encoding
parentf0646919af14efc82c68535ba60f60cbdacd712f (diff)
parent554b805093f98418a6f50a2246a8572ec0329a24 (diff)
downloadtor-eed196f122bc83d77a86a3d15659aac1201ed219.tar.gz
tor-eed196f122bc83d77a86a3d15659aac1201ed219.zip
Merge branch 'bug33032_042' into bug33032_043
Diffstat (limited to 'src/lib/encoding')
-rw-r--r--src/lib/encoding/pem.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/encoding/pem.c b/src/lib/encoding/pem.c
index c48f1016ae..6c9f10e085 100644
--- a/src/lib/encoding/pem.c
+++ b/src/lib/encoding/pem.c
@@ -85,13 +85,19 @@ pem_decode(uint8_t *dest, size_t destlen, const char *src, size_t srclen,
src = eat_whitespace_eos(src, eos);
char *tag = NULL;
- tor_asprintf(&tag, "-----BEGIN %s-----\n", objtype);
+ tor_asprintf(&tag, "-----BEGIN %s-----", objtype);
if ((size_t)(eos-src) < strlen(tag) || fast_memneq(src, tag, strlen(tag))) {
tor_free(tag);
return -1;
}
src += strlen(tag);
tor_free(tag);
+ /* At this point we insist on spaces (including CR), then an LF. */
+ src = eat_whitespace_eos_no_nl(src, eos);
+ if (src == eos || *src != '\n') {
+ /* Extra junk at end of line: this isn't valid. */
+ return -1;
+ }
// NOTE lack of trailing \n. We do not enforce its presence.
tor_asprintf(&tag, "\n-----END %s-----", objtype);