summaryrefslogtreecommitdiffhomepage
path: root/lib/rtnl.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-06-08 11:17:30 +0200
committerGitHub <noreply@github.com>2022-06-08 11:17:30 +0200
commitbdaad3b3a239c61a1d7008568e3fd7bcde2ddffe (patch)
tree838bba3d8ad545146fa32812699b77b4978aec40 /lib/rtnl.c
parent22d3d32ee3f6485da93784775624c4600f594207 (diff)
parent523566d70426aeb2afffada42cbfdd7d4b0f33ee (diff)
Merge pull request #82 from jow-/rtnl-zero-msghdr
rtnl: zero request message headers
Diffstat (limited to 'lib/rtnl.c')
-rw-r--r--lib/rtnl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/rtnl.c b/lib/rtnl.c
index 70f75d2..b2063fb 100644
--- a/lib/rtnl.c
+++ b/lib/rtnl.c
@@ -3121,6 +3121,7 @@ uc_nl_request(uc_vm_t *vm, size_t nargs)
int enable = 1, err;
struct nl_msg *msg;
struct nl_cb *cb;
+ void *buf;
size_t i;
if (ucv_type(cmd) != UC_INTEGER || ucv_int64_get(cmd) < 0 ||
@@ -3168,7 +3169,17 @@ uc_nl_request(uc_vm_t *vm, size_t nargs)
err_return(NLE_NOMEM, NULL);
if (st.spec) {
- nlmsg_reserve(msg, st.spec->headsize, 0);
+ if (st.spec->headsize) {
+ buf = nlmsg_reserve(msg, st.spec->headsize, 0);
+
+ if (!buf) {
+ nlmsg_free(msg);
+
+ return NULL;
+ }
+
+ memset(buf, 0, st.spec->headsize);
+ }
if (!uc_nl_parse_attrs(msg, NLMSG_DATA(nlmsg_hdr(msg)), st.spec->attrs, st.spec->nattrs, vm, payload)) {
nlmsg_free(msg);