dhclient: allow single hex digits in hexadecimal dhcp_client_id

When checking whether the dhcp-client-identifier is a hex string,
we expected pairs of hexadecimal digits separated by colon.
Relax this check to also allow single hex digits.

https://bugzilla.gnome.org/show_bug.cgi?id=737727

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller
2014-10-07 15:47:13 +02:00
parent dc46e2c67b
commit 7afdd9c979
2 changed files with 40 additions and 3 deletions

View File

@@ -74,16 +74,24 @@ add_hostname (GString *str, const char *format, const char *hostname)
static void
add_ip4_config (GString *str, const char *dhcp_client_id, const char *hostname)
{
if (dhcp_client_id) {
if (dhcp_client_id && *dhcp_client_id) {
gboolean is_octets = TRUE;
int i = 0;
while (dhcp_client_id[i]) {
if ((i % 3) != 2 && !g_ascii_isxdigit (dhcp_client_id[i])) {
if (!g_ascii_isxdigit (dhcp_client_id[i])) {
is_octets = FALSE;
break;
}
if ((i % 3) == 2 && dhcp_client_id[i] != ':') {
i++;
if (!dhcp_client_id[i])
break;
if (g_ascii_isxdigit (dhcp_client_id[i])) {
i++;
if (!dhcp_client_id[i])
break;
}
if (dhcp_client_id[i] != ':') {
is_octets = FALSE;
break;
}