Commit a93bd4b0 authored by Simon Kelley's avatar Simon Kelley

Fix broken DNSMASQ_USER<x> envvars in script with more than one class.

parent 407a1f3e
...@@ -1110,18 +1110,22 @@ int do_script_run(time_t now) ...@@ -1110,18 +1110,22 @@ int do_script_run(time_t now)
} }
#ifdef HAVE_SCRIPT #ifdef HAVE_SCRIPT
/* delim == -1 -> delim = 0, but embeded 0s, creating extra records, are OK. */
void lease_add_extradata(struct dhcp_lease *lease, unsigned char *data, unsigned int len, int delim) void lease_add_extradata(struct dhcp_lease *lease, unsigned char *data, unsigned int len, int delim)
{ {
unsigned int i; unsigned int i;
/* check for embeded NULLs */ if (delim == -1)
for (i = 0; i < len; i++) delim = 0;
if (data[i] == 0) else
{ /* check for embeded NULLs */
len = i; for (i = 0; i < len; i++)
break; if (data[i] == 0)
} {
len = i;
break;
}
if ((lease->extradata_size - lease->extradata_len) < (len + 1)) if ((lease->extradata_size - lease->extradata_len) < (len + 1))
{ {
size_t newsz = lease->extradata_len + len + 100; size_t newsz = lease->extradata_len + len + 100;
......
...@@ -1308,7 +1308,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1308,7 +1308,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
/* If the user-class option started as counted strings, the first byte will be zero. */ /* If the user-class option started as counted strings, the first byte will be zero. */
if (len != 0 && ucp[0] == 0) if (len != 0 && ucp[0] == 0)
ucp++, len--; ucp++, len--;
lease_add_extradata(lease, ucp, len, 0); lease_add_extradata(lease, ucp, len, -1);
} }
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment