jail: don't ignore return value of write()
authorDaniel Golle <daniel@makrotopia.org>
Wed, 4 Aug 2021 15:35:29 +0000 (16:35 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 4 Aug 2021 15:35:29 +0000 (16:35 +0100)
Check return value of write() call when writing to sysctl.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index 2fa3b2a885d0b4478f8dcc780d26bb33cf5d5c08..92ced457dd3951388bc1141e677da68621bcc2bb 100644 (file)
@@ -536,7 +536,10 @@ static int apply_sysctl(const char *jail_root)
                        ERROR("sysctl: can't open %s\n", fname);
                        return errno;
                }
-               write(f, (*cur)->value, strlen((*cur)->value));
+               if (write(f, (*cur)->value, strlen((*cur)->value)) < 0) {
+                       ERROR("sysctl: write to %s\n", fname);
+                       return errno;
+               }
 
                free(fname);
                close(f);