提交 9c1ce3dc 编写于 作者: S Stefan Berger 提交者: Stefan Berger

nwfilter: address coverity findings

This patch addresses the following coverity findings:

/libvirt/src/conf/nwfilter_params.c:157:
deref_parm: Directly dereferencing parameter "val".

/libvirt/src/conf/nwfilter_params.c:473:
negative_returns: Using variable "iterIndex" as an index to array "res->iter".

/libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:2891:
unchecked_value: No check of the return value of "virAsprintf(&protostr, "-d 01:80:c2:00:00:00 ")".

/libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:2894:
unchecked_value: No check of the return value of "virAsprintf(&protostr, "-p 0x%04x ", l3_protocols[protoidx].attr)".

/libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:3590:
var_deref_op: Dereferencing null variable "inst".
上级 9586925b
...@@ -154,6 +154,9 @@ virNWFilterVarValueGetNthValue(virNWFilterVarValuePtr val, unsigned int idx) ...@@ -154,6 +154,9 @@ virNWFilterVarValueGetNthValue(virNWFilterVarValuePtr val, unsigned int idx)
{ {
const char *res = NULL; const char *res = NULL;
if (!val)
return NULL;
switch (val->valType) { switch (val->valType) {
case NWFILTER_VALUE_TYPE_SIMPLE: case NWFILTER_VALUE_TYPE_SIMPLE:
if (idx == 0) if (idx == 0)
...@@ -467,7 +470,7 @@ virNWFilterVarCombIterCreate(virNWFilterHashTablePtr hash, ...@@ -467,7 +470,7 @@ virNWFilterVarCombIterCreate(virNWFilterHashTablePtr hash,
res->nIter++; res->nIter++;
break; break;
case VIR_NWFILTER_VAR_ACCESS_LAST: case VIR_NWFILTER_VAR_ACCESS_LAST:
break; goto err_exit;
} }
if (virNWFilterVarCombIterAddVariable(&res->iter[iterIndex], if (virNWFilterVarCombIterAddVariable(&res->iter[iterIndex],
......
...@@ -2888,10 +2888,11 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst, ...@@ -2888,10 +2888,11 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
protostr = strdup(""); protostr = strdup("");
break; break;
case L2_PROTO_STP_IDX: case L2_PROTO_STP_IDX:
virAsprintf(&protostr, "-d " NWFILTER_MAC_BGA " "); ignore_value(virAsprintf(&protostr, "-d " NWFILTER_MAC_BGA " "));
break; break;
default: default:
virAsprintf(&protostr, "-p 0x%04x ", l3_protocols[protoidx].attr); ignore_value(virAsprintf(&protostr, "-p 0x%04x ",
l3_protocols[protoidx].attr));
break; break;
} }
...@@ -3589,6 +3590,9 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3589,6 +3590,9 @@ ebiptablesApplyNewRules(const char *ifname,
int nEbtChains = 0; int nEbtChains = 0;
char *errmsg = NULL; char *errmsg = NULL;
if (inst == NULL)
nruleInstances = 0;
if (!chains_in_set || !chains_out_set) { if (!chains_in_set || !chains_out_set) {
virReportOOMError(); virReportOOMError();
goto exit_free_sets; goto exit_free_sets;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册