summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd-network/dhcp-option.c4
-rw-r--r--src/libsystemd-network/test-dhcp-option.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c
index 68950923dd..24f678c100 100644
--- a/src/libsystemd-network/dhcp-option.c
+++ b/src/libsystemd-network/dhcp-option.c
@@ -31,6 +31,10 @@ int dhcp_option_append(uint8_t options[], size_t size, size_t *offset,
assert(options);
assert(offset);
+ if (code != DHCP_OPTION_END)
+ /* always make sure there is space for an END option */
+ size --;
+
switch (code) {
case DHCP_OPTION_PAD:
diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c
index eaf6a535e6..3dd7102d82 100644
--- a/src/libsystemd-network/test-dhcp-option.c
+++ b/src/libsystemd-network/test-dhcp-option.c
@@ -85,7 +85,7 @@ static void test_invalid_buffer_length(void)
static void test_message_init(void)
{
_cleanup_free_ DHCPMessage *message = NULL;
- size_t optlen = 3, optoffset;
+ size_t optlen = 4, optoffset;
size_t len = sizeof(DHCPMessage) + optlen;
uint8_t *magic;