From: Roy Marples Date: Sun, 24 May 2020 12:02:15 +0000 (+0000) Subject: Fix some memory issues with prior X-Git-Tag: v9.1.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f1316cd8156bc9880fc693ac4f039db37493b1b;p=thirdparty%2Fdhcpcd.git Fix some memory issues with prior --- diff --git a/src/if-linux.c b/src/if-linux.c index dc0cf25b..42eeec24 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -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 diff --git a/src/privsep-bpf.c b/src/privsep-bpf.c index e3b47f08..e1fd8bc7 100644 --- a/src/privsep-bpf.c +++ b/src/privsep-bpf.c @@ -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)