Skip to content

Commit 1cbccb4

Browse files
committed
if-options: restrict nameless option defines to encap
Nameless OT_OPTION entries are only meaningful inside an encap block; a nameless top-level define/embed is unreferenceable and leaves opt->var NULL, which later crashes print_option (%s) and the embedded lookup (strcmp). Require a variable name outside O_ENCAP for both the absent-name and empty-name cases.
1 parent 4afbe3b commit 1cbccb4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/if-options.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
21062106
}
21072107
/* variable */
21082108
if (!fp) {
2109-
if (!(t & OT_OPTION)) {
2109+
if (!(t & OT_OPTION) || opt != O_ENCAP) {
21102110
logerrx("type %s requires a variable name",
21112111
arg);
21122112
return -1;
@@ -2118,7 +2118,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
21182118
if (fp)
21192119
*fp++ = '\0';
21202120
if (arg == NULL) {
2121-
if (!(t & OT_OPTION)) {
2121+
if (!(t & OT_OPTION) || opt != O_ENCAP) {
21222122
logerrx("type requires a variable name");
21232123
return -1;
21242124
}

0 commit comments

Comments
 (0)