Skip to contentSkip to conversation

master - reporter: simplify --configreport handling for -S|--select and fix an issue reported by coverity

PATCH Heinz Mauelshagen 1 participant 1 message Jul 5, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05196373bec81dcaad490a889388c57e7af1331a
Commit:        05196373bec81dcaad490a889388c57e7af1331a
Parent:        82f4f073bb7eb68aa7cb23a0c6ee75ba03fd0e57
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon Jun 27 10:14:17 2016 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Mon Jun 27 11:26:38 2016 +0200

reporter: simplify --configreport handling for -S|--select and fix an issue reported by coverity

Simplify code around _do_get_report_selection - remove "expected_idxs[]" argument which is superfluous and add "allow_single" switch instead to allow for recognition of "--configreport <report_name> -S" as well as single "-S" if needed.

Null pointer dereferences (FORWARD_NULL) /safe/guest2/covscan/LVM2.2.02.158/tools/reporter.c: 961 in _do_report_get_selection() Null pointer dereferences (FORWARD_NULL) Dereferencing null pointer "single_args".

---
 lib/report/report.h |    2 +-
 tools/reporter.c    |   60 +++++++++++++++++++++++----------------------------
 tools/toollib.c     |    2 +-
 3 files changed, 29 insertions(+), 35 deletions(-)
lib/report/report.h +1 -1
index b9028fe..ba3a8fa 100644
@@ -90,7 +90,7 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
 		  int aligned, int buffered, int headings, int field_prefixes,
 		  int quoted, int columns_as_rows, const char *selection,
 		  int multiple_output);
-int report_get_single_selection(struct cmd_context *cmd, const char **selection);
+int report_get_single_selection(struct cmd_context *cmd, report_type_t report_type, const char **selection);
 void *report_init_for_selection(struct cmd_context *cmd, report_type_t *report_type,
 				const char *selection);
 int report_get_prefix_and_desc(report_type_t report_type_id,
tools/reporter.c +27 -33

142 lines not on this page · raw message

tools/toollib.c +1 -1
index 80d0f32..4c24b16 100644
@@ -1771,7 +1771,7 @@ int init_selection_handle(struct cmd_context *cmd, struct processing_handle *han
 		return 0;
 	}
 
-	if (!report_get_single_selection(cmd, &selection))
+	if (!report_get_single_selection(cmd, initial_report_type, &selection))
 		return_0;
 
 	sh->report_type = initial_report_type;