summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2011-03-17 16:03:11 +0100
committerThomas Graf <tgraf@suug.ch>2011-03-17 16:03:11 +0100
commit5a9f50b8e9be45094acbe313b31a81ceaabc6c96 (patch)
treed577fdb81950a580942f3223a319adba3d137621
parentae5dfb1cc7268c5134a1ee1c911f3792b80ff7ea (diff)
downloadlibnl-5a9f50b8e9be45094acbe313b31a81ceaabc6c96.tar.gz
__nlmsg_alloc(): Guarantee minimal message size of at least the header
-rw-r--r--lib/msg.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/msg.c b/lib/msg.c
index 95ad188..5c852c0 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -400,6 +400,9 @@ static struct nl_msg *__nlmsg_alloc(size_t len)
{
struct nl_msg *nm;
+ if (len < sizeof(struct nlmsghdr))
+ len = sizeof(struct nlmsghdr);
+
nm = calloc(1, sizeof(*nm));
if (!nm)
goto errout;