diff --git a/client/config_init.c b/client/config_init.c index 41d9ae04..d39ac0b0 100644 --- a/client/config_init.c +++ b/client/config_init.c @@ -100,29 +100,25 @@ parse_time_offset(char *offset_str) break; } } + offset_digits[j] = '\0'; + if (j < 1) { fprintf(stderr, "[*] Invalid time offset: %s", offset_str); exit(EXIT_FAILURE); } offset = atoi(offset_digits); + if (offset < 0) { fprintf(stderr, "[*] Invalid time offset: %s", offset_str); exit(EXIT_FAILURE); } - switch (offset_type) { - case TIME_OFFSET_MINUTES: - offset *= 60; - break; - case TIME_OFFSET_HOURS: - offset *= 60 * 60; - break; - case TIME_OFFSET_DAYS: - offset *= 60 * 60 * 24; - break; - } + /* Apply the offset_type value + */ + offset *= offset_type; + return offset; } @@ -183,7 +179,7 @@ parse_config_file(fko_cli_options_t *options, struct opts_track* ot) if (*lptr == '#' || *lptr == '\n' || *lptr == '\r' || *lptr == '\0' || *lptr == ';') continue; -/*--DSS TODO: Figure out what to put here +/*--DSS TODO: Figure out what to put here (these are just samples below) if (ot->got_device == 0 || options->interface.name[0] == '\0') get_char_val("XXXX", options->interface.name, lptr); diff --git a/client/fwknop.c b/client/fwknop.c index a9a2f85f..4bec0888 100644 --- a/client/fwknop.c +++ b/client/fwknop.c @@ -506,6 +506,7 @@ get_save_file(char *args_save_file) homedir, "/", ".fwknop.run"); rv = 1; } + return rv; } @@ -598,37 +599,26 @@ set_message_type(fko_ctx_t ctx, fko_cli_options_t *options) if (options->nat_local) { if (options->fw_timeout >= 0) - { message_type = FKO_CLIENT_TIMEOUT_LOCAL_NAT_ACCESS_MSG; - } else - { message_type = FKO_LOCAL_NAT_ACCESS_MSG; - } } else { if (options->fw_timeout >= 0) - { message_type = FKO_CLIENT_TIMEOUT_NAT_ACCESS_MSG; - } else - { message_type = FKO_NAT_ACCESS_MSG; - } } } else { if (options->fw_timeout >= 0) - { message_type = FKO_CLIENT_TIMEOUT_ACCESS_MSG; - } else - { message_type = FKO_ACCESS_MSG; - } } + return fko_set_spa_message_type(ctx, message_type); }