mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Fix broken DNSMASQ_USER<x> envvars in script with more than one class.
This commit is contained in:
20
src/lease.c
20
src/lease.c
@@ -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,
|
|||||||
/* 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
|
||||||
|
|||||||
Reference in New Issue
Block a user