[OpenWrt-Devel] [PATCH] procd sysupgrade: close input side of pipe before reading

Rafał Miłecki zajec5 at gmail.com
Sun Oct 27 09:44:52 EDT 2019


On Thu, 3 Oct 2019 at 18:24, Dustin Lundquist
<D.Lundquist at temperednetworks.com> wrote:
> When /usr/libexec/validate_firmware_image is not present on the system
> procd will hang indefinitely on the read() since the input side of the
> pipe is still open.
>
> Signed-off-by: Dustin Lundquist <d.lundquist at temperednetworks.com>
> ---
> system.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/system.c b/system.c
> index 751a016..a7ada13 100644
> --- a/system.c
> +++ b/system.c
> @@ -425,6 +425,7 @@ static int validate_firmware_image_call(const char *file)
>         }
>
>         /* Parent process */
> +       close(fds[1]);
>
>         tok = json_tokener_new();
>         if (!tok) {
> @@ -447,7 +448,6 @@ static int validate_firmware_image_call(const char *file)
>         }
>
>         close(fds[0]);
> -       close(fds[1]);
>
>         err = -ENOENT;
>         if (jsobj) {

You also need to drop close(fds[1]); that is placed inside the "if
(!tok)" block.

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list