udev: link-config - fix corruption
The parser used for MTU and Speed expects them to be size_t, not unsigned int. This caused a corruption in the rest of the structure. Reported by David O Neill <david.m.oneill@intel.com>.
This commit is contained in:
parent
3641cff2f1
commit
dab495dc23
|
@ -174,6 +174,9 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
|
||||||
else
|
else
|
||||||
log_debug("Parsed configuration file %s", filename);
|
log_debug("Parsed configuration file %s", filename);
|
||||||
|
|
||||||
|
if (link->mtu > UINT_MAX || link->speed > UINT_MAX)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
link->filename = strdup(filename);
|
link->filename = strdup(filename);
|
||||||
|
|
||||||
LIST_PREPEND(links, ctx->links, link);
|
LIST_PREPEND(links, ctx->links, link);
|
||||||
|
@ -376,10 +379,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
if (!old_name)
|
if (!old_name)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024,
|
r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024, config->duplex);
|
||||||
config->duplex);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning_errno(r, "Could not set speed or duplex of %s to %u Mbps (%s): %m",
|
log_warning_errno(r, "Could not set speed or duplex of %s to %zu Mbps (%s): %m",
|
||||||
old_name, config->speed / 1024,
|
old_name, config->speed / 1024,
|
||||||
duplex_to_string(config->duplex));
|
duplex_to_string(config->duplex));
|
||||||
|
|
||||||
|
@ -458,8 +460,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
mac = config->mac;
|
mac = config->mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rtnl_set_link_properties(&ctx->rtnl, ifindex, config->alias, mac,
|
r = rtnl_set_link_properties(&ctx->rtnl, ifindex, config->alias, mac, config->mtu);
|
||||||
config->mtu);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_warning_errno(r, "Could not set Alias, MACAddress or MTU on %s: %m", old_name);
|
return log_warning_errno(r, "Could not set Alias, MACAddress or MTU on %s: %m", old_name);
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ struct link_config {
|
||||||
NamePolicy *name_policy;
|
NamePolicy *name_policy;
|
||||||
char *name;
|
char *name;
|
||||||
char *alias;
|
char *alias;
|
||||||
unsigned int mtu;
|
size_t mtu;
|
||||||
unsigned int speed;
|
size_t speed;
|
||||||
Duplex duplex;
|
Duplex duplex;
|
||||||
WakeOnLan wol;
|
WakeOnLan wol;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue