File dhcp-4.2.1-dhclient6-zero-length-options.patch of Package dhcp.import5685
From 8164c6ca7e54da9ed201993468872eb10fa527b4 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 5 Jan 2012 16:28:50 +0100
Subject: [PATCH] zero-length option lease parse error in dhclient6
common/parse.c:
Use peek_token only or the next_token call behind the while loop
will cause two warnings / errors in the log:
lease line XX: semicolon expected.
lease line XX: Unexpected end of file.
[there is a } behind the semicolon as the next token in my case]
and the option (lease?) gets discarded.
To reproduce, use "send dhcp6.rapid-commit;" to /etc/dhclient6.conf,
remove the lease file and start the client. When the lease is bound,
kill the client and start it again.
client/dhclient.c:
More of cosmetic nature - do not print zero-length options like there
would be a value missed, e.g. " option dhcp6.rapid-commit ;".
Signed-off-by: Marius Tomaschewski <mt@suse.de>
---
client/dhclient.c | 11 ++++++++---
common/parse.c | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index da83b55..b8e1855 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -2701,10 +2701,15 @@ void write_lease_option (struct option_cache *oc,
}
if (evaluate_option_cache (&ds, packet, lease, client_state,
in_options, cfg_options, scope, oc, MDL)) {
- fprintf(leaseFile, "%soption %s%s%s %s;\n", preamble,
- name, dot, oc->option->name,
- pretty_print_option(oc->option, ds.data, ds.len,
+ if(oc->option->format && oc->option->format[0] == 'Z' && ds.len == 0) {
+ fprintf(leaseFile, "%soption %s%s%s;\n", preamble,
+ name, dot, oc->option->name);
+ } else {
+ fprintf(leaseFile, "%soption %s%s%s %s;\n", preamble,
+ name, dot, oc->option->name,
+ pretty_print_option(oc->option, ds.data, ds.len,
1, 1));
+ }
data_string_forget (&ds, MDL);
}
}
diff --git a/common/parse.c b/common/parse.c
index b4a821b..40da698 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -5606,7 +5606,7 @@ int parse_option_decl (oc, cfile)
goto alloc;
case 'Z': /* Zero-length option */
- token = next_token(&val, (unsigned *)0, cfile);
+ token = peek_token(&val, (unsigned *)0, cfile);
if (token != SEMI) {
parse_warn(cfile,
"semicolon expected.");
--
1.7.7