Prevents segfaults when there's no blank line between the URI
section and the public key, as well as when the file is empty.
Fixes #1.
* trouble. We'll have to decode the TAL's SPKI though.
*/
+ /*
+ * TODO we're decoding the TAL's public key, but the stacked file name
+ * is the certificate's. It looks weird when it errors.
+ */
tal_get_spki(tal, &_tal_spki, &_tal_spki_len);
error = asn1_decode(_tal_spki, _tal_spki_len,
&asn_DEF_SubjectPublicKeyInfo, (void **) &tal_spki);
if (error)
return error;
+ if (uri == NULL)
+ return pr_err("TAL file is empty.");
if (strcmp(uri, "") == 0) {
free(uri);
- return pr_err("TAL file contains no URIs");
+ return pr_err("There's no URI in the first line of the TAL.");
}
error = uris_add(uris, uri);
if (error)
return error;
+ if (uri == NULL)
+ return pr_err("TAL file ended prematurely. (Expected URI list, blank line and public key.)");
if (strcmp(uri, "") == 0) {
free(uri);
return 0; /* Happy path */