From: Alberto Leiva Popper Date: Wed, 2 Feb 2022 23:56:54 +0000 (-0600) Subject: URI: Panic on invalid getters X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc2a5418f5c36f6be3ed68917c56a1154acadf25;p=thirdparty%2FFORT-validator.git URI: Panic on invalid getters Some URIs don't have meaningful local or global paths. I checked the call hierarchy, and the code sensibly steers away from the corresponding getters in those cases. I added null checks, to future-proof the constraint. --- diff --git a/src/types/uri.c b/src/types/uri.c index 5d5b74ef..f0606793 100644 --- a/src/types/uri.c +++ b/src/types/uri.c @@ -240,22 +240,24 @@ uri_refput(struct rpki_uri *uri) } /* - * This function only really makes sense during or after the file download. - * Otherwise it'll just return the arbitrary first global. - * * Note, if you're trying to print the URI, then you should most likely use * uri_*_get_printable() instead. */ char const * uri_get_global(struct rpki_uri *uri) { + if (uri->global == NULL) /* See clear_caged_directory() */ + pr_crit("URI's global path is not meaningful."); + return uri->global; } -/* Can return NULL. TODO (aaaa) Review callers. */ char const * uri_get_local(struct rpki_uri *uri) { + if (uri->local == NULL) /* See URI_TYPE_VOID. */ + pr_crit("URI's local path is not meaningful."); + return uri->local; }