diff options
author | Thomas Haller <thaller@redhat.com> | 2022-01-28 21:20:05 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-01-29 16:22:31 +0100 |
commit | 64630f57a2f5cf48e1010d2976065dcd46427609 (patch) | |
tree | 6d5ad3b42fc29bc03553e961cc6ecd72eb508b67 | |
parent | d501e968579826e0c6e99c46a6ac959925432216 (diff) | |
download | NetworkManager-64630f57a2f5cf48e1010d2976065dcd46427609.tar.gz |
device/wwan: ensure capabilities are suitable 32 bit flags
The properties NM_DEVICE_MODEM_CAPABILITIES and
NM_DEVICE_MODEM_CURRENT_CAPABILITIES are uint, with a range from zero to
G_MAXUINT32.
nm_modem_get_capabilities() passes the "untrusted" flags from
ModemManager. Ensure that they fit into 32 bit, and don't cause an
assertion failure due to the range check.
Yes, in practice, on all platforms where we build (known to me), guint
is always the same as guint32. So this has little effect.
Also, cast to guint. Previously, this was just a C enum
NMDeviceModemCapabilities, which theoretically has implementation
defined sizes. Yes, in practice, they too are of size guint, and this
was not an actual bug. But be specific about converting between
different integer types.
-rw-r--r-- | src/core/devices/wwan/nm-device-modem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 4a0d9e4435..ef802a44f2 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -762,9 +762,9 @@ nm_device_modem_new(NMModem *modem) NM_DEVICE_MODEM_MODEM, modem, NM_DEVICE_MODEM_CAPABILITIES, - caps, + (guint) ((guint32) caps), NM_DEVICE_MODEM_CURRENT_CAPABILITIES, - current_caps, + (guint) ((guint32) current_caps), NM_DEVICE_MODEM_DEVICE_ID, nm_modem_get_device_id(modem), NULL); |