diff options
-rw-r--r-- | src/certtool-cfg.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c index f3341bb413..80e8ae8252 100644 --- a/src/certtool-cfg.c +++ b/src/certtool-cfg.c @@ -213,7 +213,7 @@ read_crq_set (gnutls_x509_crq crq, const char *input_str, const char *oid) } int -read_int (const char *input_str) +read_int_with_default (const char *input_str, int def) { char *in; char *endptr; @@ -237,11 +237,20 @@ read_int (const char *input_str) return 0; } + if (in == endptr) + l = def; + free (in); return (int) l; } +int +read_int (const char *input_str) +{ + return read_int_with_default (input_str, 0); +} + const char * read_str (const char *input_str) { @@ -612,8 +621,8 @@ get_path_len (void) } else { - return - read_int ("Path length constraint (decimal, -1 for no constraint): "); + return read_int_with_default + ("Path length constraint (decimal, -1 for no constraint): ", -1); } } |