#ifdef PRIVSEP
if (ctx->options & DHCPCD_PRIVSEP &&
!(ctx->options & DHCPCD_PRIVSEPROOT))
- return ps_root_filemtime(ctx, file, time);
+ return (int)ps_root_filemtime(ctx, file, time);
#else
UNUSED(ctx);
#endif
#ifdef PRIVSEP
if (ctx->options & DHCPCD_PRIVSEP &&
!(ctx->options & DHCPCD_PRIVSEPROOT))
- return ps_root_unlink(ctx, file);
+ return (int)ps_root_unlink(ctx, file);
#else
UNUSED(ctx);
#endif
} buf;
struct dhcp_state *state = D_STATE(ifp);
struct bootp *lease;
- ssize_t bytes;
+ ssize_t sbytes;
+ size_t bytes;
uint8_t type;
#ifdef AUTH
const uint8_t *auth;
if (state->leasefile[0] == '\0') {
logdebugx("reading standard input");
- bytes = read(fileno(stdin), buf.buf, sizeof(buf.buf));
+ sbytes = read(fileno(stdin), buf.buf, sizeof(buf.buf));
} else {
logdebugx("%s: reading lease `%s'",
ifp->name, state->leasefile);
- bytes = dhcp_readfile(ifp->ctx, state->leasefile,
+ sbytes = dhcp_readfile(ifp->ctx, state->leasefile,
buf.buf, sizeof(buf.buf));
}
- if (bytes == -1) {
+ if (sbytes == -1) {
if (errno != ENOENT)
logerr("%s: %s", ifp->name, state->leasefile);
return 0;
}
+ bytes = (size_t)sbytes;
/* Ensure the packet is at lease BOOTP sized
* with a vendor area of 4 octets
* (it should be more, and our read packet enforces this so this
* code should not be needed, but of course people could
* scribble whatever in the stored lease file. */
- if ((size_t)bytes < DHCP_MIN_LEN) {
+ if (bytes < DHCP_MIN_LEN) {
logerrx("%s: %s: truncated lease", ifp->name, __func__);
return 0;
}
return 0;
}
memcpy(*bootp, buf.buf, bytes);
- return (size_t)bytes;
+ return bytes;
}
static const struct dhcp_opt *
state->acquired.tv_sec -= now - mtime;
/* Check to see if the lease is still valid */
- fd = dhcp6_validatelease(ifp, &buf.dhcp6, bytes, NULL,
+ fd = dhcp6_validatelease(ifp, &buf.dhcp6, (size_t)bytes, NULL,
&state->acquired);
if (fd == -1)
goto ex;
auth:
#ifdef AUTH
/* Authenticate the message */
- o = dhcp6_findmoption(&buf.dhcp6, bytes, D6_OPTION_AUTH, &ol);
+ o = dhcp6_findmoption(&buf.dhcp6, (size_t)bytes, D6_OPTION_AUTH, &ol);
if (o) {
if (dhcp_auth_validate(&state->auth, &ifp->options->auth,
- buf.buf, bytes, 6, buf.dhcp6.type, o, ol) == NULL)
+ buf.buf, (size_t)bytes, 6, buf.dhcp6.type, o, ol) == NULL)
{
logerr("%s: authentication failed", ifp->name);
bytes = 0;
out:
free(state->new);
- state->new = malloc(bytes);
+ state->new = malloc((size_t)bytes);
if (state->new == NULL) {
logerr(__func__);
goto ex;
}
- memcpy(state->new, buf.buf, bytes);
- state->new_len = bytes;
+ memcpy(state->new, buf.buf, (size_t)bytes);
+ state->new_len = (size_t)bytes;
return bytes;
ex:
do {
p = *buf;
- c = memchr(*buf, '\n', *buflen);
+ c = memchr(*buf, '\n', (size_t)*buflen);
if (c == NULL) {
- c = memchr(*buf, '\0', *buflen);
+ c = memchr(*buf, '\0', (size_t)*buflen);
if (c == NULL)
return NULL;
*buflen = c - *buf;
char buf[UDPLEN_MAX], *bp; /* 64k max config file size */
char *line, *option, *p;
ssize_t buflen;
- ssize_t vlen;
+ size_t vlen;
int skip, have_profile, new_block, had_block;
#if !defined(INET) || !defined(INET6)
size_t i;
buf[buflen] = '\0';
}
#else
- buflen = strlcpy(buf, dhcpcd_embedded_conf, sizeof(buf));
+ buflen = (ssize_t)strlcpy(buf, dhcpcd_embedded_conf,
+ sizeof(buf));
if ((size_t)buflen >= sizeof(buf)) {
logerrx("%s: embedded config too big", __func__);
return ifo;
return -1;
}
nc++;
- return writefile(file, mode, nc, len - (nc - file));
+ return writefile(file, mode, nc, len - (size_t)(nc - file));
}
static ssize_t
}
break;
case PS_WRITEFILE:
- err = ps_root_dowritefile(psm->ps_flags, data, len);
+ err = ps_root_dowritefile((mode_t)psm->ps_flags, data, len);
break;
case PS_FILEMTIME:
err = filemtime(data, &mtime);
return ps_root_readerror(ctx, NULL, 0);
}
-int
+ssize_t
ps_root_filemtime(struct dhcpcd_ctx *ctx, const char *file, time_t *time)
{
ssize_t ps_root_readerror(struct dhcpcd_ctx *, void *, size_t);
ssize_t ps_root_ioctl(struct dhcpcd_ctx *, ioctl_request_t, void *, size_t);
ssize_t ps_root_unlink(struct dhcpcd_ctx *, const char *);
-int ps_root_filemtime(struct dhcpcd_ctx *, const char *, time_t *);
+ssize_t ps_root_filemtime(struct dhcpcd_ctx *, const char *, time_t *);
ssize_t ps_root_readfile(struct dhcpcd_ctx *, const char *, void *, size_t);
ssize_t ps_root_writefile(struct dhcpcd_ctx *, const char *, mode_t,
const void *, size_t);