From fc2a5418f5c36f6be3ed68917c56a1154acadf25 Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Wed, 2 Feb 2022 17:56:54 -0600 Subject: [PATCH] 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. --- src/types/uri.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; } -- 2.47.3