pem: Don't read beyond line ends
authorTobias Brunner <tobias@strongswan.org>
Wed, 29 Mar 2017 09:19:30 +0000 (11:19 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 23 May 2017 16:29:11 +0000 (18:29 +0200)
src/libstrongswan/plugins/pem/pem_builder.c

index 719a2a6..cda7037 100644 (file)
@@ -61,7 +61,7 @@ static bool find_boundary(char* tag, chunk_t *line)
 
        if (!present("-----", line) ||
                !present(tag, line) ||
-               *line->ptr != ' ')
+               !line->len || *line->ptr != ' ')
        {
                return FALSE;
        }
@@ -306,7 +306,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
                                }
 
                                /* check for PGP armor checksum */
-                               if (*data.ptr == '=')
+                               if (data.len && *data.ptr == '=')
                                {
                                        *pgp = TRUE;
                                        data.ptr++;