aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2020-06-30 13:48:49 +0000
committerAlexander Færøy <ahf@torproject.org>2020-06-30 13:48:49 +0000
commit483082b57bfb2535477530fe84d8c92c70be2fa1 (patch)
tree445b76b652d86a3cde5fe738930b4d7faae9f4a1 /src/lib
parentb0bfee8c783b495ece772189d478dad2628bc159 (diff)
parentc3ad2a1d2367d6c0ba5c1c81491770056e881a77 (diff)
downloadtor-483082b57bfb2535477530fe84d8c92c70be2fa1.tar.gz
tor-483082b57bfb2535477530fe84d8c92c70be2fa1.zip
Merge branch 'maint-0.3.5' into maint-0.4.2
Diffstat (limited to 'src/lib')
-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 24b238b130..51f37d0840 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);