diff options
author | Bryan Cantrill <bryan@joyent.com> | 2017-07-14 18:27:31 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2017-09-25 18:48:01 +0000 |
commit | b2f2652061ea587b1b2b4e246659e1d7e7313f42 (patch) | |
tree | 163a3b75f1ea2b41537a1913ff506dbc309c8378 /usr/src/cmd/flowadm | |
parent | 745cad278f6b2e392001dd1bf6b4e95d3f250a8d (diff) | |
download | illumos-gate-b2f2652061ea587b1b2b4e246659e1d7e7313f42.tar.gz |
8507 dladm show-link segfaults if you specify too many fields
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Ryan Zezeski <ryan.zeseski@joyent.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/cmd/flowadm')
-rw-r--r-- | usr/src/cmd/flowadm/flowadm.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/usr/src/cmd/flowadm/flowadm.c b/usr/src/cmd/flowadm/flowadm.c index 374fa1675c..058c1e03d8 100644 --- a/usr/src/cmd/flowadm/flowadm.c +++ b/usr/src/cmd/flowadm/flowadm.c @@ -23,6 +23,10 @@ * Use is subject to license terms. */ +/* + * Copyright 2017 Joyent, Inc. + */ + #include <stdio.h> #include <locale.h> #include <stdarg.h> @@ -81,7 +85,6 @@ static void warn_dlerr(dladm_status_t, const char *, ...); /* callback functions for printing output */ static ofmt_cb_t print_flowprop_cb, print_default_cb; -static void flowadm_ofmt_check(ofmt_status_t, boolean_t, ofmt_handle_t); typedef struct cmd { char *c_name; @@ -642,7 +645,7 @@ do_show_flow(int argc, char *argv[]) } oferr = ofmt_open(fields_str, flow_fields, ofmtflags, 0, &ofmt); - flowadm_ofmt_check(oferr, state.fs_parsable, ofmt); + ofmt_check(oferr, state.fs_parsable, ofmt, die, warn); state.fs_ofmt = ofmt; /* Show attributes of one flow */ @@ -1186,7 +1189,7 @@ do_show_flowprop(int argc, char **argv) state.fs_status = DLADM_STATUS_OK; oferr = ofmt_open(fields_str, flowprop_fields, ofmtflags, 0, &ofmt); - flowadm_ofmt_check(oferr, state.fs_parsable, ofmt); + ofmt_check(oferr, state.fs_parsable, ofmt, die, warn); state.fs_ofmt = ofmt; /* Show properties for one flow */ @@ -1277,26 +1280,3 @@ print_default_cb(ofmt_arg_t *of_arg, char *buf, uint_t bufsize) (void) strlcpy(buf, value, bufsize); return (B_TRUE); } - -static void -flowadm_ofmt_check(ofmt_status_t oferr, boolean_t parsable, - ofmt_handle_t ofmt) -{ - char buf[OFMT_BUFSIZE]; - - if (oferr == OFMT_SUCCESS) - return; - (void) ofmt_strerror(ofmt, oferr, buf, sizeof (buf)); - /* - * All errors are considered fatal in parsable mode. - * NOMEM errors are always fatal, regardless of mode. - * For other errors, we print diagnostics in human-readable - * mode and processs what we can. - */ - if (parsable || oferr == OFMT_ENOFIELDS) { - ofmt_close(ofmt); - die(buf); - } else { - warn(buf); - } -} |