diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-11-18 15:36:04 -0800 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-11-18 15:36:04 -0800 |
| commit | db7c85284f7a1c472da0e905a0020ed02d37f539 (patch) | |
| tree | e64915779a5cc411fbcd2894bc328899391b6ce5 /lib/json.c | |
| parent | eb2674af89fbd4a81867528ffc0884191182bcb9 (diff) | |
Quagga: Fixup cli and json keyword
The json keyword was being read incorrectly.
Basically some commands read a variable # of arguments
and in ospf the command values were being placed into
argc and argv. With a variable # of arguments their
existed a possibility that less arguments would be read
from the cli than were being tested for in the command function
handler. This caused core dumps in some situations.
All code to read to decide to use the json keyword has
been centralized through a function and all code
converted to use it, irrelevant if it exhibited the bug
Ticket: CM-8278
Reviewed by: CCR-3830
Testing: OSPF no longer crashes and all other test suites still run
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/json.c')
| -rw-r--r-- | lib/json.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/json.c b/lib/json.c index 07b70e4f06..f78bfcd844 100644 --- a/lib/json.c +++ b/lib/json.c @@ -19,8 +19,26 @@ * 02111-1307, USA. */ +#include <string.h> #include "lib/json.h" +/* + * This function assumes that the json keyword + * is the *last* keyword on the line no matter + * what. + */ +int +use_json (const int argc, const char *argv[]) +{ + if (argc == 0) + return 0; + + if (argv[argc-1] && strcmp(argv[argc-1], "json") == 0) + return 1; + + return 0; +} + void json_object_string_add(struct json_object* obj, const char *key, const char *s) |
