aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-04-27 20:56:21 +0000
committerMark Johnston <markj@FreeBSD.org>2026-04-28 20:32:11 +0000
commit5a5e7883a3bb85cbdcf9e2fc0f40b0a391659c30 (patch)
tree58606424a4b2b27d69da6d8823ef737cbf004e8b
parenta2d45189b9eec1ebf33f4ee844c4098c2f345447 (diff)
dhclient: Fix reallocation of dhclient script environments
When the number of DHCP options exceeds a threshold, script_set_env() will reallocate the environment, stored as an array of pointers. The calculation of the array size failed to multiply by the pointer size, resulting in a smaller than expected buffer which admits out-of-bounds writes. Approved by: so Security: FreeBSD-SA-26:15.dhclient Security: CVE-2026-42511 Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
-rw-r--r--sbin/dhclient/dhclient.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 590b18ee6467..e8fcdb133dc4 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -2435,8 +2435,8 @@ script_set_env(struct client_state *client, const char *prefix,
char **newscriptEnv;
int newscriptEnvsize = client->scriptEnvsize + 50;
- newscriptEnv = realloc(client->scriptEnv,
- newscriptEnvsize);
+ newscriptEnv = reallocarray(client->scriptEnv,
+ newscriptEnvsize, sizeof(char *));
if (newscriptEnv == NULL) {
free(client->scriptEnv);
client->scriptEnv = NULL;