mirror of
https://github.com/ipxe/ipxe
synced 2026-01-01 00:07:27 +03:00
[settings] Explicitly separate the concept of a completed fetched setting
The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -49,8 +49,8 @@ static int copy_encap_settings ( struct dhcp_packet *dest,
|
||||
struct setting setting = { .name = "" };
|
||||
unsigned int subtag;
|
||||
unsigned int tag;
|
||||
void *data;
|
||||
int len;
|
||||
int check_len;
|
||||
int rc;
|
||||
|
||||
for ( subtag = DHCP_MIN_OPTION; subtag <= DHCP_MAX_OPTION; subtag++ ) {
|
||||
@@ -66,17 +66,11 @@ static int copy_encap_settings ( struct dhcp_packet *dest,
|
||||
default:
|
||||
/* Copy setting, if present */
|
||||
setting.tag = tag;
|
||||
len = fetch_setting_len ( source, &setting );
|
||||
if ( len < 0 )
|
||||
break;
|
||||
{
|
||||
char buf[len];
|
||||
|
||||
check_len = fetch_setting ( source, &setting,
|
||||
buf, sizeof (buf));
|
||||
assert ( check_len == len );
|
||||
if ( ( rc = dhcppkt_store ( dest, tag, buf,
|
||||
sizeof(buf) )) !=0)
|
||||
len = fetch_raw_setting_copy ( source, &setting, &data);
|
||||
if ( len >= 0 ) {
|
||||
rc = dhcppkt_store ( dest, tag, data, len );
|
||||
free ( data );
|
||||
if ( rc != 0 )
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user