Skip to content

Commit 33df3ed

Browse files
authored
options: Ensure that an overly long bitflag string does not crash (#576)
Fixes #573.
1 parent 63bfc6d commit 33df3ed

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/if-options.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
21302130
ndop->var = np;
21312131
if (bp) {
21322132
dl = strlen(bp);
2133+
if (dl > sizeof(ndop->bitflags)) {
2134+
logwarnx("bitflag string too long %s", bp);
2135+
dl = sizeof(ndop->bitflags);
2136+
}
21332137
memcpy(ndop->bitflags, bp, dl);
21342138
memset(ndop->bitflags + dl, 0,
21352139
sizeof(ndop->bitflags) - dl);

0 commit comments

Comments
 (0)