]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Send only what we have put in the buffer to script env
authorRoy Marples <roy@marples.name>
Wed, 19 Jul 2023 11:42:49 +0000 (12:42 +0100)
committerRoy Marples <roy@marples.name>
Wed, 19 Jul 2023 13:30:01 +0000 (14:30 +0100)
Rather then sending the whole buffer size.
If there is an error writing the last option, it may not be
NUL terminated correctly causing an assert.
Even so, we should not write the failed option to the environment
either as it would be a false positive for an empty option.

src/script.c

index 6173b4020f384fb7643e053c9868f1ea1e90c861..45b04f90423ef68c745e23e6b1b40b16598d5439 100644 (file)
@@ -764,7 +764,7 @@ script_runreason(const struct interface *ifp, const char *reason)
 #ifdef PRIVSEP
        if (ctx->options & DHCPCD_PRIVSEP) {
                if (ps_root_script(ctx,
-                   ctx->script_buf, ctx->script_buflen) == -1)
+                   ctx->script_buf, (size_t)buflen) == -1)
                        logerr(__func__);
                goto send_listeners;
        }