pem: Make sure we actually parsed some data
authorTobias Brunner <tobias@strongswan.org>
Tue, 10 Nov 2020 17:14:36 +0000 (18:14 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 13 Nov 2020 15:40:01 +0000 (16:40 +0100)
This could happen if there is no separating empty line between header
and body.

References #3627.

src/libstrongswan/plugins/pem/pem_builder.c

index e9d464f..3b84eb7 100644 (file)
@@ -330,7 +330,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
        /* set length to size of binary blob */
        blob->len = dst.len;
 
-       if (state != PEM_POST)
+       if (state != PEM_POST || !blob->len)
        {
                DBG1(DBG_LIB, "  file coded in unknown format, discarded");
                return PARSE_ERROR;