]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: reduce buflen by 2 when creating a new RFC 3396 option
authorBillie Alsup <balsup@cisco.com>
Sat, 7 Dec 2024 07:42:38 +0000 (07:42 +0000)
committerRoy Marples <roy@marples.name>
Sat, 7 Dec 2024 07:42:38 +0000 (07:42 +0000)
Fixes #418 and potential buffer overflow.

src/dhcp.c

index 11c69bc1eb54c0301ddc40a3ac40f9cc5c4d98e3..9e23ab620189a6c63bf2d222e8159889a630679a 100644 (file)
@@ -752,6 +752,7 @@ rfc3396_write(struct rfc3396_ctx *ctx, void *data, size_t len)
                        *(*ctx->buf)++ = ctx->code;
                        ctx->len = (*ctx->buf)++;
                        *ctx->len = 0;
+                       ctx->buflen -= 2;
                        r += 2;
                }