Skip to content

Commit ec8f583

Browse files
committed
Fix guards for prior
1 parent 5272125 commit ec8f583

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/privsep-bsd.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,21 @@ ps_root_doindirectioctl(struct dhcpcd_ctx *ctx,
158158
return -1;
159159
}
160160
memcpy(&ifnamelen, p, sizeof(ifnamelen));
161+
len -= sizeof(ifnamelen);
161162

162-
if (len < ifnamelen || len > sizeof(ifr.ifr_name)) {
163+
if (len < ifnamelen || ifnamelen > sizeof(ifr.ifr_name)) {
163164
errno = EINVAL;
164165
return -1;
165166
}
166167

167168
memcpy(ifr.ifr_name, p, ifnamelen);
168169
len -= ifnamelen;
169170

170-
/* Ensure data is now aligned */
171-
memmove(data, p + ifnamelen, len);
172-
ifr.ifr_data = data;
171+
if (len != 0) {
172+
/* Ensure data is now aligned */
173+
memmove(data, p + ifnamelen, len);
174+
ifr.ifr_data = data;
175+
}
173176

174177
return ps_root_doioctldom(ctx, PF_INET, req, &ifr, sizeof(ifr));
175178
}

0 commit comments

Comments
 (0)