Selaa lähdekoodia

[dhcp] Allow DHCP non-option settings to be cleared

dhcppkt_store() is supposed to clear the setting if passed NULL for the
setting data.  In the case of fixed-location fields (e.g. client IP
address), this requires setting the content of the field to all-zeros.
tags/v0.9.4
Michael Brown 16 vuotta sitten
vanhempi
commit
2df682c5be
1 muutettua tiedostoa jossa 3 lisäystä ja 0 poistoa
  1. 3
    0
      src/net/dhcppkt.c

+ 3
- 0
src/net/dhcppkt.c Näytä tiedosto

@@ -138,12 +138,15 @@ find_dhcp_packet_field ( unsigned int tag ) {
138 138
 int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
139 139
 		    const void *data, size_t len ) {
140 140
 	struct dhcp_packet_field *field;
141
+	void *field_data;
141 142
 	int rc;
142 143
 
143 144
 	/* If this is a special field, fill it in */
144 145
 	if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
145 146
 		if ( len > field->len )
146 147
 			return -ENOSPC;
148
+		field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
149
+		memset ( field_data, 0, field->len );
147 150
 		memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
148 151
 			 data, len );
149 152
 		return 0;

Loading…
Peruuta
Tallenna