]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix some memory issues with prior
authorRoy Marples <roy@marples.name>
Sun, 24 May 2020 12:02:15 +0000 (12:02 +0000)
committerRoy Marples <roy@marples.name>
Sun, 24 May 2020 12:02:15 +0000 (12:02 +0000)
src/if-linux.c
src/privsep-bpf.c

index dc0cf25bd7d6a6f176f60f9d3b0af9be6e7086b8..42eeec2444bec13977dbfcf33532647dcf358206 100644 (file)
@@ -255,9 +255,12 @@ static ssize_t
 if_writepathuint(struct dhcpcd_ctx *ctx, const char *path, unsigned int val)
 {
        char buf[64];
+       int len;
 
-       snprintf(buf, sizeof(buf), "%u\n", val);
-       return dhcp_writefile(ctx, path, 0664, buf, sizeof(buf));
+       len = snprintf(buf, sizeof(buf), "%u\n", val);
+       if (len == -1)
+               return -1;
+       return dhcp_writefile(ctx, path, 0664, buf, (size_t)len);
 }
 
 int
index e3b47f082e485e76b52475f1520cbbb5f5179f7a..e1fd8bc72ece783b406ca28085c1cec5c1add513 100644 (file)
@@ -81,7 +81,7 @@ ps_bpf_recvbpf(void *arg)
                        break;
                psm.ps_flags = bpf->bpf_flags;
                len = ps_sendpsmdata(psp->psp_ctx, psp->psp_ctx->ps_data_fd,
-                   &psm, buf, (size_t)len + sizeof(bpf->bpf_flags));
+                   &psm, buf, (size_t)len);
                if (len == -1 && errno != ECONNRESET)
                        logerr(__func__);
                if (len == -1 || len == 0)