Procházet zdrojové kódy

[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 před 16 roky
rodič
revize
2df682c5be
1 změnil soubory, kde provedl 3 přidání a 0 odebrání
  1. 3
    0
      src/net/dhcppkt.c

+ 3
- 0
src/net/dhcppkt.c Zobrazit soubor

@@ -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;

Načítá se…
Zrušit
Uložit