diff options
| author | Bryan Cantrill <bryan@joyent.com> | 2017-05-12 20:53:05 +0000 |
|---|---|---|
| committer | Bryan Cantrill <bryan@joyent.com> | 2017-05-15 23:42:11 +0000 |
| commit | c5bf6dbcaf952d0108897703c878c1c0eb4be27f (patch) | |
| tree | 824a414cbcbfaa82d814f9e40a949f3ceb739a5f /usr/src/cmd/flowstat/flowstat.c | |
| parent | d7b3c0f0f9f6c7bd9fbafc475db0d96a54372712 (diff) | |
| download | illumos-joyent-c5bf6dbcaf952d0108897703c878c1c0eb4be27f.tar.gz | |
OS-6057 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>
Approved by: Ryan Zezeski <ryan.zeseski@joyent.com>
Diffstat (limited to 'usr/src/cmd/flowstat/flowstat.c')
| -rw-r--r-- | usr/src/cmd/flowstat/flowstat.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/usr/src/cmd/flowstat/flowstat.c b/usr/src/cmd/flowstat/flowstat.c index faabd74a14..ab1797922c 100644 --- a/usr/src/cmd/flowstat/flowstat.c +++ b/usr/src/cmd/flowstat/flowstat.c @@ -21,7 +21,10 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright 2011 Joyent, Inc. All rights reserved. + */ + +/* + * Copyright 2017 Joyent, Inc. */ #include <stdio.h> @@ -87,7 +90,6 @@ static void warn(const char *, ...); /* callback functions for printing output */ static ofmt_cb_t print_default_cb, print_flow_stats_cb; -static void flowstat_ofmt_check(ofmt_status_t, boolean_t, ofmt_handle_t); #define NULL_OFMT {NULL, 0, 0, NULL} @@ -719,7 +721,7 @@ main(int argc, char *argv[]) } oferr = ofmt_open(fields_str, flow_s_fields, ofmtflags, 0, &ofmt); - flowstat_ofmt_check(oferr, state.fs_parsable, ofmt); + ofmt_check(oferr, state.fs_parsable, ofmt, die, warn); state.fs_ofmt = ofmt; for (;;) { @@ -987,7 +989,7 @@ do_show_history(int argc, char *argv[]) 0, &ofmt); } - flowstat_ofmt_check(oferr, state.us_parsable, ofmt); + ofmt_check(oferr, state.us_parsable, ofmt, die, warn); state.us_ofmt = ofmt; if (F_arg && d_arg) @@ -1116,26 +1118,3 @@ print_default_cb(ofmt_arg_t *of_arg, char *buf, uint_t bufsize) (void) strlcpy(buf, value, bufsize); return (B_TRUE); } - -static void -flowstat_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); - } -} |
