-/* $OpenBSD: clparse.c,v 1.72 2014/01/17 22:48:10 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.73 2014/01/18 00:51:55 krw Exp $ */
/* Parser for dhclient config and lease files. */
parse_client_statement(FILE *cfile)
{
u_int8_t optlist[256];
- int code, count;
+ int code, count, token;
- switch (next_token(NULL, cfile)) {
+ token = next_token(NULL, cfile);
+
+ switch (token) {
case TOK_SEND:
parse_option_decl(cfile, &config->send_options[0]);
break;
break;
default:
parse_warn("expecting a statement.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
break;
}
}
if (token != TOK_NUMBER && token !=
TOK_NUMBER_OR_NAME) {
parse_warn("expecting hexadecimal constant.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return (-1);
}
convert_num(&buf[len], val, 16, 8);
memcpy(buf, val, len + 1);
} else {
parse_warn("expecting string or hexadecimal data");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return (-1);
}
return (len);
return (ix);
syntaxerror:
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return (-1);
}
token = next_token(&val, cfile);
if (token != TOK_STRING) {
parse_warn("expecting interface name (in quotes).");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
token = next_token(&val, cfile);
if (token != '{') {
parse_warn("expecting left brace.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
token = next_token(NULL, cfile);
if (token != '{') {
parse_warn("expecting left brace.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
char *val;
int token;
- switch (next_token(&val, cfile)) {
+ token = next_token(&val, cfile);
+
+ switch (token) {
case TOK_BOOTP:
lease->is_bootp = 1;
break;
token = next_token(&val, cfile);
if (token != TOK_STRING) {
parse_warn("expecting interface name (in quotes).");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
if (strcmp(ifi->name, val) != 0) {
return;
default:
parse_warn("expecting lease declaration.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
token = next_token(&val, cfile);
if (token != TOK_STRING) {
parse_warn("expecting string.");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return (-1);
}
len = strlen(val);
-/* $OpenBSD: parse.c,v 1.31 2014/01/13 23:42:18 krw Exp $ */
+/* $OpenBSD: parse.c,v 1.32 2014/01/18 00:51:55 krw Exp $ */
/* Common parser code for dhcpd and dhclient. */
token = next_token(&val, cfile);
if (token != TOK_STRING) {
parse_warn("filename must be a string");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return (NULL);
}
s = strdup(val);
token = next_token(NULL, cfile);
if (token != TOK_ETHERNET) {
parse_warn("expecting 'ethernet'");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
token = next_token(&val, cfile);
if (token != TOK_NUMBER) {
parse_warn("Expecting numeric lease time");
- skip_to_semi(cfile);
+ if (token != ';')
+ skip_to_semi(cfile);
return;
}
convert_num((unsigned char *)&value, val, 10, 32);