diff options
author | Thomas Haller <thaller@redhat.com> | 2022-04-23 16:50:28 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-04-23 16:50:53 (GMT) |
commit | 23a75c5b3b9e7e1a3d418136f229eba9533f6fdd (patch) | |
tree | d6ec5502b91593919f5fd30e042409baafd1f5b1 | |
parent | d52dbcb611a4c409db5e265858b13eef1609b044 (diff) | |
download | libnl-23a75c5b3b9e7e1a3d418136f229eba9533f6fdd.zip libnl-23a75c5b3b9e7e1a3d418136f229eba9533f6fdd.tar.gz libnl-23a75c5b3b9e7e1a3d418136f229eba9533f6fdd.tar.bz2 |
xfrm: fix uninitalized variables in build_xfrm_ae_message()
Error: UNINIT (CWE-457):
libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer.
libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.flags" is uninitialized when calling "nlmsg_append".
# 400| return -NLE_NOMEM;
# 401|···
# 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0)
# 403| goto nla_put_failure;
# 404|···
Error: UNINIT (CWE-457):
libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer.
libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.reqid" is uninitialized when calling "nlmsg_append".
# 400| return -NLE_NOMEM;
# 401|···
# 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0)
# 403| goto nla_put_failure;
# 404|···
Error: UNINIT (CWE-457):
libnl-3.6.0/lib/xfrm/ae.c:377: var_decl: Declaring variable "ae_id" without initializer.
libnl-3.6.0/lib/xfrm/ae.c:402: uninit_use_in_call: Using uninitialized value "ae_id". Field "ae_id.saddr" is uninitialized when calling "nlmsg_append".
# 400| return -NLE_NOMEM;
# 401|···
# 402|-> if (nlmsg_append(msg, &ae_id, sizeof(ae_id), NLMSG_ALIGNTO) < 0)
# 403| goto nla_put_failure;
# 404|···
-rw-r--r-- | lib/xfrm/ae.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/xfrm/ae.c b/lib/xfrm/ae.c index b8039e3..3af872f 100644 --- a/lib/xfrm/ae.c +++ b/lib/xfrm/ae.c @@ -382,6 +382,8 @@ static int build_xfrm_ae_message(struct xfrmnl_ae *tmpl, int cmd, int flags, !(tmpl->ce_mask & XFRM_AE_ATTR_PROTO)) return -NLE_MISSING_ATTR; + memset(&ae_id, 0, sizeof(ae_id)); + memcpy (&ae_id.sa_id.daddr, nl_addr_get_binary_addr (tmpl->sa_id.daddr), sizeof (uint8_t) * nl_addr_get_len (tmpl->sa_id.daddr)); ae_id.sa_id.spi = htonl(tmpl->sa_id.spi); ae_id.sa_id.family = tmpl->sa_id.family; |