gtlscertificate: Fix bug in PEM private key parser

Make sure to not go outside of PEM data buffer when looking for private
key.

Also adding test case that triggers this bug.
This commit is contained in:
Fredrik Ternerot
2018-12-14 11:46:27 +01:00
parent e8fb8322ce
commit feff178c3f
2 changed files with 12 additions and 3 deletions

View File

@@ -258,7 +258,7 @@ parse_private_key (const gchar *data,
}
}
end = g_strstr_len (start, data_len - (data - start), footer);
end = g_strstr_len (start, data_len - (start - data), footer);
if (!end)
{
g_set_error_literal (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE,