]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix bugs at snapshot processing, and uint args parsing.
authorpcarana <pc.moreno2099@gmail.com>
Wed, 15 Jan 2020 21:56:04 +0000 (15:56 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Wed, 15 Jan 2020 21:56:04 +0000 (15:56 -0600)
+The errors raised during snapshot files processing were ignored. Despite the affected files were deleted, the validation flow kept going, thus presenting an incorrect behavior.
+Unsigned integer arguments were treating an empty string as '0'.

src/config/uint.c
src/rrdp/rrdp_loader.c
src/rrdp/rrdp_parser.c

index af2464b9c98ed86f84204e43f23a5a0f368f1928..007bf5326384c0b5680ef87b46a4fdad3d0db641 100644 (file)
@@ -3,6 +3,7 @@
 #include <getopt.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 #include "log.h"
 
 static void
@@ -18,7 +19,8 @@ parse_argv_uint(struct option_field const *field, char const *str,
        char *tmp;
        unsigned long parsed;
 
-       if (field->type->has_arg != required_argument || str == NULL) {
+       if (field->type->has_arg != required_argument || str == NULL ||
+                   strlen(str) == 0) {
                return pr_err("Integer options ('%s' in this case) require an argument.",
                    field->name);
        }
index ef29a42fd7c199d78d58c740d00c4aaba61821d2..40913b48de71c720579a2529c4006151f486c3a3 100644 (file)
@@ -126,21 +126,19 @@ rrdp_load(struct rpki_uri *uri)
                pr_crit("Unexpected RRDP URI comparison result");
        }
 
-       /* Any change, and no error during the process, update db */
-       if (!error) {
-               pr_debug("Updating local RRDP data of '%s' to:",
-                   uri_get_global(uri));
-               pr_debug("- Session ID: %s",
-                   upd_notification->global_data.session_id);
-               pr_debug("- Serial: %lu",
-                   upd_notification->global_data.serial);
-               error = db_rrdp_uris_update(uri_get_global(uri),
-                   upd_notification->global_data.session_id,
-                   upd_notification->global_data.serial,
-                   visited);
-               if (error)
-                       goto end;
-       }
+       if (error)
+               goto end;
+
+       /* Any update, and no error during the process, update db as well */
+       pr_debug("Updating local RRDP data of '%s' to:", uri_get_global(uri));
+       pr_debug("- Session ID: %s", upd_notification->global_data.session_id);
+       pr_debug("- Serial: %lu", upd_notification->global_data.serial);
+       error = db_rrdp_uris_update(uri_get_global(uri),
+           upd_notification->global_data.session_id,
+           upd_notification->global_data.serial,
+           visited);
+       if (error)
+               goto end;
 
 set_update:
        /* Set the last update to now */
index 7cedf2e80914e4389ffcd8bcb471c3489ce11288..9780b0afda002804af8b88826e1e83c42467515e 100644 (file)
@@ -659,7 +659,7 @@ delete_from_uri(struct rpki_uri *uri, struct visited_uris *visited_uris)
        return delete_dir_recursive_bottom_up(uri_get_local(uri));
 }
 
-int
+static int
 __delete_from_uri(char const *location, struct visited_uris *visited_uris)
 {
        struct rpki_uri *uri;