mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 21:10:08 +01:00
core: use larger buffer for string in commit_port_options()
Use sizeof(queue_id_str), so we don't rely on _MAX_QUEUE_ID_STR_LEN being the correct size for the string. Also, let's create an excessively large buffer. True, the previous size should have always be enough, so in practice there is no difference. But what if it were not? Should we try to handle an error? How? Just asserting or report a failure? But we don't because the error cannot happen, can't it? Don't answer any of these questions, but by making the string buffer larger, it's even less likely that these questions become relevant. If for some reason nm_device_get_iface() gives a long string, then we don't care and let kernel reject the invalid interface name.
This commit is contained in:
parent
047d2c1d92
commit
1d0e526b03
1 changed files with 2 additions and 8 deletions
|
|
@ -407,16 +407,10 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* The queue id format is '$interface_name:$queue_id'
|
||||
* The max queue 65535 hold 5 chars.
|
||||
*/
|
||||
#define _MAX_QUEUE_ID_STR_LEN 5 + IFNAMSIZ + 1 + 1
|
||||
|
||||
static void
|
||||
commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *set_port)
|
||||
{
|
||||
char queue_id_str[_MAX_QUEUE_ID_STR_LEN];
|
||||
char queue_id_str[IFNAMSIZ + NM_STRLEN(":") + 5 + 100];
|
||||
|
||||
/*
|
||||
* The queue-id of bond port is read only, we should modify bond interface using:
|
||||
|
|
@ -424,7 +418,7 @@ commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *se
|
|||
* Kernel allows parital editing, so no need to care about other bond ports.
|
||||
*/
|
||||
g_snprintf(queue_id_str,
|
||||
_MAX_QUEUE_ID_STR_LEN,
|
||||
sizeof(queue_id_str),
|
||||
"%s:%" G_GUINT32_FORMAT,
|
||||
nm_device_get_iface(port),
|
||||
set_port ? nm_setting_bond_port_get_queue_id(set_port) : NM_BOND_PORT_QUEUE_ID_DEF);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue