diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/nsoption.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/nsoption.c b/utils/nsoption.c index e4354bf3f..6754d2131 100644 --- a/utils/nsoption.c +++ b/utils/nsoption.c @@ -822,14 +822,22 @@ nsoption_snoptionf(char *string, int fmtc = 0; /* current index into format string */ struct nsoption_s *option; - if (option_idx >= NSOPTION_LISTEND) { + if (fmt == NULL) { return -1; } - option = &nsoptions[option_idx]; /* assume the global table */ - if (option == NULL || option->key == NULL) + if ((option_idx < 0) || (option_idx >= NSOPTION_LISTEND)) { + return -1; + } + + if (nsoptions == NULL) { return -1; + } + option = &nsoptions[option_idx]; /* assume the global table */ + if (option == NULL || option->key == NULL) { + return -1; + } while ((slen < size) && (fmt[fmtc] != 0)) { if (fmt[fmtc] == '%') { |