Fix bit-rotted data handling code for LUA scripts.

This commit is contained in:
Simon Kelley
2022-07-31 11:33:05 +01:00
parent 6578acd668
commit 05e6728e98
3 changed files with 14 additions and 15 deletions

View File

@@ -450,8 +450,10 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
buf = grab_extradata_lua(buf, end, "circuit_id"); buf = grab_extradata_lua(buf, end, "circuit_id");
buf = grab_extradata_lua(buf, end, "subscriber_id"); buf = grab_extradata_lua(buf, end, "subscriber_id");
buf = grab_extradata_lua(buf, end, "remote_id"); buf = grab_extradata_lua(buf, end, "remote_id");
buf = grab_extradata_lua(buf, end, "requested_options");
} }
buf = grab_extradata_lua(buf, end, "mud_url");
buf = grab_extradata_lua(buf, end, "tags"); buf = grab_extradata_lua(buf, end, "tags");
if (is6) if (is6)
@@ -633,16 +635,14 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
buf = grab_extradata(buf, end, "DNSMASQ_CIRCUIT_ID", &err); buf = grab_extradata(buf, end, "DNSMASQ_CIRCUIT_ID", &err);
buf = grab_extradata(buf, end, "DNSMASQ_SUBSCRIBER_ID", &err); buf = grab_extradata(buf, end, "DNSMASQ_SUBSCRIBER_ID", &err);
buf = grab_extradata(buf, end, "DNSMASQ_REMOTE_ID", &err); buf = grab_extradata(buf, end, "DNSMASQ_REMOTE_ID", &err);
buf = grab_extradata(buf, end, "DNSMASQ_MUD_URL", &err);
buf = grab_extradata(buf, end, "DNSMASQ_REQUESTED_OPTIONS", &err); buf = grab_extradata(buf, end, "DNSMASQ_REQUESTED_OPTIONS", &err);
} }
buf = grab_extradata(buf, end, "DNSMASQ_MUD_URL", &err);
buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err); buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err);
if (is6) { if (is6)
buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err); buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err);
buf = grab_extradata(buf, end, "DNSMASQ_MUD_URL", &err);
}
else else
{ {
const char *giaddr = NULL; const char *giaddr = NULL;

View File

@@ -1417,9 +1417,6 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
add_extradata_opt(lease, NULL); add_extradata_opt(lease, NULL);
} }
if ((opt = option_find(mess, sz, OPTION_MUD_URL_V4, 1)))
add_extradata_opt(lease, opt);
/* DNSMASQ_REQUESTED_OPTIONS */ /* DNSMASQ_REQUESTED_OPTIONS */
if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1))) if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 1)))
{ {
@@ -1438,6 +1435,8 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
add_extradata_opt(lease, NULL); add_extradata_opt(lease, NULL);
} }
add_extradata_opt(lease, option_find(mess, sz, OPTION_MUD_URL_V4, 1));
/* space-concat tag set */ /* space-concat tag set */
if (!tagif_netid) if (!tagif_netid)
add_extradata_opt(lease, NULL); add_extradata_opt(lease, NULL);

View File

@@ -1905,6 +1905,11 @@ static void update_leases(struct state *state, struct dhcp_context *context, str
lease_add_extradata(lease, (unsigned char *)state->client_hostname, lease_add_extradata(lease, (unsigned char *)state->client_hostname,
state->client_hostname ? strlen(state->client_hostname) : 0, 0); state->client_hostname ? strlen(state->client_hostname) : 0, 0);
if ((opt = opt6_find(state->packet_options, state->end, OPTION6_MUD_URL, 1)))
lease_add_extradata(lease, opt6_ptr(opt, 0), opt6_len(opt), 0);
else
lease_add_extradata(lease, NULL, 0, 0);
/* space-concat tag set */ /* space-concat tag set */
if (!tagif && !context->netid.net) if (!tagif && !context->netid.net)
lease_add_extradata(lease, NULL, 0, 0); lease_add_extradata(lease, NULL, 0, 0);
@@ -1934,11 +1939,6 @@ static void update_leases(struct state *state, struct dhcp_context *context, str
lease_add_extradata(lease, (unsigned char *)daemon->addrbuff, state->link_address ? strlen(daemon->addrbuff) : 0, 0); lease_add_extradata(lease, (unsigned char *)daemon->addrbuff, state->link_address ? strlen(daemon->addrbuff) : 0, 0);
if ((opt = opt6_find(state->packet_options, state->end, OPTION6_MUD_URL, 1)))
lease_add_extradata(lease, opt6_ptr(opt, 0), opt6_len(opt), 0);
else
lease_add_extradata(lease, NULL, 0, 0);
if ((opt = opt6_find(state->packet_options, state->end, OPTION6_USER_CLASS, 2))) if ((opt = opt6_find(state->packet_options, state->end, OPTION6_USER_CLASS, 2)))
{ {
void *enc_opt, *enc_end = opt6_ptr(opt, opt6_len(opt)); void *enc_opt, *enc_end = opt6_ptr(opt, opt6_len(opt));