From: pcarana Date: Wed, 15 Jan 2020 21:56:04 +0000 (-0600) Subject: Fix bugs at snapshot processing, and uint args parsing. X-Git-Tag: v1.2.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecaecc1fd4259aafc38289c242621566a4e57572;p=thirdparty%2FFORT-validator.git Fix bugs at snapshot processing, and uint args parsing. +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'. --- diff --git a/src/config/uint.c b/src/config/uint.c index af2464b9..007bf532 100644 --- a/src/config/uint.c +++ b/src/config/uint.c @@ -3,6 +3,7 @@ #include #include #include +#include #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); } diff --git a/src/rrdp/rrdp_loader.c b/src/rrdp/rrdp_loader.c index ef29a42f..40913b48 100644 --- a/src/rrdp/rrdp_loader.c +++ b/src/rrdp/rrdp_loader.c @@ -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 */ diff --git a/src/rrdp/rrdp_parser.c b/src/rrdp/rrdp_parser.c index 7cedf2e8..9780b0af 100644 --- a/src/rrdp/rrdp_parser.c +++ b/src/rrdp/rrdp_parser.c @@ -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;