dhclient - Try harder to re-initialize parsing state.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sat, 4 Aug 2012 18:55:19 +0000 (20:55 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Wed, 15 Aug 2012 01:22:19 +0000 (03:22 +0200)
- Attempt that nothing accidentally carries over when
  a new file (i.e. leases after config) is parsed.
  May help with mysterious "Corrupt lease file" messages.

Taken-from: OpenBSD

sbin/dhclient/conflex.c

index a4698e1..fc988e3 100644 (file)
@@ -1,5 +1,4 @@
-/*     $OpenBSD: conflex.c,v 1.13 2006/12/17 17:41:56 stevesk Exp $    */
-/*     $DragonFly: src/sbin/dhclient/conflex.c,v 1.1 2008/08/30 16:07:58 hasso Exp $   */
+/*     $OpenBSD: src/sbin/dhclient/conflex.c,v 1.14 2011/12/10 17:36:40 krw Exp $      */
 
 /* Lexical scanner for dhclient config file... */
 
@@ -76,12 +75,25 @@ static int intern(char *, int);
 void
 new_parse(char *name)
 {
-       tlname = name;
+       /*
+        * Initialize all parsing state, as we are starting to parse a
+        * new file, 'name'.
+        */
+
+       bzero(line1, sizeof(line1));
+       bzero(line2, sizeof(line2));
+       bzero(tokbuf, sizeof(tokbuf));
+
        lpos = line = 1;
+       tlpos = tline = token = ugflag = 0;
+       tval = NULL;
+
+       lexline = lexchar = 0;
        cur_line = line1;
        prev_line = line2;
        token_line = cur_line;
-       cur_line[0] = prev_line[0] = 0;
+       tlname = name;
+
        warnings_occurred = 0;
 }