|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 6f42877282a7237f3aa840403047b7cc18d7faa6 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Tom Gundersen <teg@jklm.no>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 17 Sep 2014 19:07:56 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] libsystemd-network: dhcp-test - assert that malloc0 succeeds
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Otherwise we would get a nullptr dereference later on.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Found by coverity. Fixes CID #1237655.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-network/test-dhcp-option.c | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 1 insertion(+)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7a0fac8d33..63cdc7aa06 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-network/test-dhcp-option.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-network/test-dhcp-option.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -115,6 +115,7 @@ static DHCPMessage *create_message(uint8_t *options, uint16_t optlen,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t len = sizeof(DHCPMessage) + optlen;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
message = malloc0(len);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(message);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (options && optlen)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
memcpy(&message->options, options, optlen);
|