|
@@ -180,26 +180,36 @@ static int resize_dhcp_option ( struct dhcp_options *options,
|
180
|
180
|
void *end;
|
181
|
181
|
|
182
|
182
|
/* Check for sufficient space, and update length fields */
|
183
|
|
- if ( new_len > DHCP_MAX_LEN )
|
|
183
|
+ if ( new_len > DHCP_MAX_LEN ) {
|
|
184
|
+ DBGC ( options, "DHCPOPT %p overlength option\n", options );
|
184
|
185
|
return -ENOSPC;
|
|
186
|
+ }
|
185
|
187
|
new_options_len = ( options->len + delta );
|
186
|
188
|
if ( new_options_len > options->max_len ) {
|
187
|
189
|
/* Reallocate options block if allowed to do so. */
|
188
|
190
|
if ( can_realloc ) {
|
189
|
191
|
new_data = realloc ( options->data, new_options_len );
|
190
|
|
- if ( ! new_data )
|
|
192
|
+ if ( ! new_data ) {
|
|
193
|
+ DBGC ( options, "DHCPOPT %p could not "
|
|
194
|
+ "reallocate to %zd bytes\n", options,
|
|
195
|
+ new_options_len );
|
191
|
196
|
return -ENOMEM;
|
|
197
|
+ }
|
192
|
198
|
options->data = new_data;
|
193
|
199
|
options->max_len = new_options_len;
|
194
|
200
|
} else {
|
|
201
|
+ DBGC ( options, "DHCPOPT %p out of space\n", options );
|
195
|
202
|
return -ENOMEM;
|
196
|
203
|
}
|
197
|
204
|
}
|
198
|
205
|
if ( encap_offset >= 0 ) {
|
199
|
206
|
encapsulator = dhcp_option ( options, encap_offset );
|
200
|
207
|
new_encapsulator_len = ( encapsulator->len + delta );
|
201
|
|
- if ( new_encapsulator_len > DHCP_MAX_LEN )
|
|
208
|
+ if ( new_encapsulator_len > DHCP_MAX_LEN ) {
|
|
209
|
+ DBGC ( options, "DHCPOPT %p overlength encapsulator\n",
|
|
210
|
+ options );
|
202
|
211
|
return -ENOSPC;
|
|
212
|
+ }
|
203
|
213
|
encapsulator->len = new_encapsulator_len;
|
204
|
214
|
}
|
205
|
215
|
options->len = new_options_len;
|
|
@@ -253,7 +263,7 @@ static int set_dhcp_option ( struct dhcp_options *options, unsigned int tag,
|
253
|
263
|
options, dhcp_tag_name ( tag ), old_len, new_len );
|
254
|
264
|
} else {
|
255
|
265
|
DBGC ( options, "DHCPOPT %p creating %s (length %zd)\n",
|
256
|
|
- options, dhcp_tag_name ( tag ), len );
|
|
266
|
+ options, dhcp_tag_name ( tag ), new_len );
|
257
|
267
|
}
|
258
|
268
|
|
259
|
269
|
/* Ensure that encapsulator exists, if required */
|
|
@@ -353,7 +363,7 @@ int dhcpopt_fetch ( struct dhcp_options *options, unsigned int tag,
|
353
|
363
|
return offset;
|
354
|
364
|
|
355
|
365
|
option = dhcp_option ( options, offset );
|
356
|
|
- option_len = dhcp_option_len ( option );
|
|
366
|
+ option_len = option->len;
|
357
|
367
|
if ( len > option_len )
|
358
|
368
|
len = option_len;
|
359
|
369
|
memcpy ( data, option->data, len );
|