summaryrefslogtreecommitdiff
path: root/epan/print.c
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-04-04 13:26:21 +0200
committerMartin Kaiser <wireshark@kaiser.cx>2015-04-04 17:09:02 +0000
commite4da62fefe4f52cccca28875c0e893e69a184152 (patch)
treef3e2ea759568cede76de28f014163454445f5dd8 /epan/print.c
parentf1803dbbb72c5b007a39f5617635a2ec68732b58 (diff)
downloadwireshark-e4da62fefe4f52cccca28875c0e893e69a184152.tar.gz
Coverity 1158848, 1158849 (logically dead code)
the option parameter of output_fields_set_option() is always a 0-terminated string therefore, option_value can't possibly be NULL, remove the NULL checks if someone runs 'tshark ... -E header=', option_value is an empty string, bail out in this case, don't parse *option_value and *(option_value++) in the switch statements Change-Id: I734b04aff653e8dbe990f546220595546e7503b0 Reviewed-on: https://code.wireshark.org/review/7904 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/print.c')
-rw-r--r--epan/print.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/epan/print.c b/epan/print.c
index 8e3794c5cd..ad4ef5cc0d 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -1117,8 +1117,12 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
return FALSE;
}
option_value = option + strlen(option_name) + 1;
+ if (*option_value == '\0') {
+ return FALSE;
+ }
+
if (0 == strcmp(option_name, "header")) {
- switch (NULL == option_value ? '\0' : *option_value) {
+ switch (*option_value) {
case 'n':
info->print_header = FALSE;
break;
@@ -1132,9 +1136,7 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
}
if (0 == strcmp(option_name, "separator")) {
- switch (NULL == option_value ? '\0' : *option_value) {
- case '\0':
- return FALSE;
+ switch (*option_value) {
case '/':
switch (*++option_value) {
case 't':
@@ -1155,7 +1157,7 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
}
if (0 == strcmp(option_name, "occurrence")) {
- switch (NULL == option_value ? '\0' : *option_value) {
+ switch (*option_value) {
case 'f':
case 'l':
case 'a':
@@ -1168,9 +1170,7 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
}
if (0 == strcmp(option_name, "aggregator")) {
- switch (NULL == option_value ? '\0' : *option_value) {
- case '\0':
- return FALSE;
+ switch (*option_value) {
case '/':
switch (*++option_value) {
case 's':
@@ -1188,11 +1188,7 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
}
if (0 == strcmp(option_name, "quote")) {
- switch (NULL == option_value ? '\0' : *option_value) {
- default: /* Fall through */
- case '\0':
- info->quote = '\0';
- return FALSE;
+ switch (*option_value) {
case 'd':
info->quote = '"';
break;
@@ -1202,6 +1198,9 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
case 'n':
info->quote = '\0';
break;
+ default:
+ info->quote = '\0';
+ return FALSE;
}
return TRUE;
}