summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-06-09 01:51:59 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-06-09 01:51:59 +0000
commit27eb54c0632f1183bb62a4c94cb7146f7bd7dace (patch)
treee1b40f1a8eafadb9f857f5e0d5311a05650acc85 /sbin/dhclient
parent62cd772e155cf9f07d0e4fae1afa8ffb5a794219 (diff)
Add back backslash fixes caught in rollback.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/conflex.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c
index d6be36f8c42..02533c4ef83 100644
--- a/sbin/dhclient/conflex.c
+++ b/sbin/dhclient/conflex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conflex.c,v 1.21 2013/06/09 00:30:06 krw Exp $ */
+/* $OpenBSD: conflex.c,v 1.22 2013/06/09 01:51:58 krw Exp $ */
/* Lexical scanner for dhclient config file. */
@@ -233,34 +233,29 @@ skip_to_eol(FILE *cfile)
static int
read_string(FILE *cfile)
{
- int i, c, bs = 0;
+ int i, c, bs;
- for (i = 0; i < sizeof(tokbuf); i++) {
+ bs = i = 0;
+ do {
c = get_char(cfile);
- if (c == EOF) {
- parse_warn("eof in string constant");
- break;
- }
- if (bs) {
+ if (bs)
bs = 0;
- tokbuf[i] = c;
- } else if (c == '\\')
+ else if (c == '\\')
bs = 1;
- else if (c == '"')
- break;
- else
- tokbuf[i] = c;
- }
- /*
- * Normally, I'd feel guilty about this, but we're talking about
- * strings that'll fit in a DHCP packet here.
- */
- if (i == sizeof(tokbuf)) {
+
+ if (c != '"' && c != EOF && bs == 0)
+ tokbuf[i++] = c;
+
+ } while (i < (sizeof(tokbuf) - 1) && c != EOF && c != '"');
+
+ if (c == EOF)
+ parse_warn("eof in string constant");
+ else if (c != '"')
parse_warn("string constant larger than internal buffer");
- i--;
- }
+
tokbuf[i] = 0;
tval = tokbuf;
+
return (TOK_STRING);
}