]> 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 11:42:49 +0000 (12:42 +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 94101d4d628c66996a59dd9acc2c9827f9c60758..2ef99e38f7cec47dfe5e853ae5d8b4e5b1cda2a8 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;
        }