Fix broken DNSMASQ_USER<x> envvars in script with more than one class.
diff --git a/src/lease.c b/src/lease.c
index a4c06c8..20cac90 100644
--- a/src/lease.c
+++ b/src/lease.c
@@ -1110,18 +1110,22 @@
}
#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)
{
unsigned int i;
- /* check for embeded NULLs */
- for (i = 0; i < len; i++)
- if (data[i] == 0)
- {
- len = i;
- break;
- }
-
+ if (delim == -1)
+ delim = 0;
+ else
+ /* check for embeded NULLs */
+ for (i = 0; i < len; i++)
+ if (data[i] == 0)
+ {
+ len = i;
+ break;
+ }
+
if ((lease->extradata_size - lease->extradata_len) < (len + 1))
{
size_t newsz = lease->extradata_len + len + 100;
diff --git a/src/rfc2131.c b/src/rfc2131.c
index e21efb5..f3c8895 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -1308,7 +1308,7 @@
/* If the user-class option started as counted strings, the first byte will be zero. */
if (len != 0 && ucp[0] == 0)
ucp++, len--;
- lease_add_extradata(lease, ucp, len, 0);
+ lease_add_extradata(lease, ucp, len, -1);
}
}
#endif