diff options
author | George Kadianakis <desnacked@riseup.net> | 2020-03-23 16:56:59 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-03-23 16:56:59 +0200 |
commit | 29420ab396cffb4b3c062b76fc859cc01f2206b7 (patch) | |
tree | 56497cdf4e786cf3e85a11b774fcb5a8731814f6 /src/lib/encoding/pem.c | |
parent | e380396d423deded74e6c0e6f6f767a1cc93df04 (diff) | |
parent | eed196f122bc83d77a86a3d15659aac1201ed219 (diff) | |
download | tor-29420ab396cffb4b3c062b76fc859cc01f2206b7.tar.gz tor-29420ab396cffb4b3c062b76fc859cc01f2206b7.zip |
Merge branch 'tor-github/pr/1788' into maint-0.4.3
Diffstat (limited to 'src/lib/encoding/pem.c')
-rw-r--r-- | src/lib/encoding/pem.c | 8 |
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); |