]> granicus.if.org Git - libnl/commitdiff
xfrm: fix memleak in another error path of build_xfrm_sa_message
authorPeter Wu <peter@lekensteyn.nl>
Mon, 8 Aug 2016 09:58:51 +0000 (11:58 +0200)
committerThomas Haller <thaller@redhat.com>
Sun, 14 Aug 2016 07:57:25 +0000 (09:57 +0200)
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: Thomas Haller <thaller@redhat.com>
lib/xfrm/sa.c

index 74b7ee9883fc8dadd0b6e090c9f0fbbdd6a6d685..9e2c353caad49a46cde3537f77b4d2009831a5fc 100644 (file)
@@ -1175,7 +1175,10 @@ static int build_xfrm_sa_message(struct xfrmnl_sa *tmpl, int cmd, int flags, str
                        strncpy(auth->alg_name, tmpl->auth->alg_name, sizeof(auth->alg_name));
                        auth->alg_key_len = tmpl->auth->alg_key_len;
                        memcpy(auth->alg_key, tmpl->auth->alg_key, (tmpl->auth->alg_key_len + 7) / 8);
-                       NLA_PUT(msg, XFRMA_ALG_AUTH, len, auth);
+                       if (nla_put(msg, XFRMA_ALG_AUTH, len, auth) < 0) {
+                               free(auth);
+                               goto nla_put_failure;
+                       }
                        free(auth);
                }
        }