]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
URI: Panic on invalid getters
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 2 Feb 2022 23:56:54 +0000 (17:56 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 2 Feb 2022 23:56:54 +0000 (17:56 -0600)
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

index 5d5b74efd9dcc3d1f3a519eadab0346a44f057e5..f0606793254a4408521b0ebb1a9d62db09a614d5 100644 (file)
@@ -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;
 }