Commit graph

23745 commits

Author SHA1 Message Date
Thomas Haller
fb49607de1 libnm/doc: add missing "Since: 1.20" comments
(cherry picked from commit e48089b039)
2019-08-06 12:22:16 +02:00
Thomas Haller
fa0c5a41c1 ifupdown: fix assertion during logging %NULL storage in load_eni_ifaces()
(cherry picked from commit ddb08e3602)
2019-08-06 12:22:15 +02:00
Thomas Haller
3cef1b98cc libnm/doc: add Since tag for %NM_SETTING_IP6_CONFIG_METHOD_DISABLED
(cherry picked from commit f988e85025)
2019-08-06 11:52:08 +02:00
Thomas Haller
9374aa5f2f NEWS: update 2019-08-06 11:51:17 +02:00
Beniamino Galvani
47c772354e modem: fix memory leak
Fixes: 9b935fad9b ('modem: don't use GAsyncResult pattern for disconnecting modem')
(cherry picked from commit 22cd9e754b)
2019-08-06 09:17:10 +02:00
Beniamino Galvani
df5d76b0dc libnm-core: fix ifcfg-rh variable name for DHCPv6 hostname
Fixes: 2852b50945 ('ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars')
(cherry picked from commit 657b8b31b0)
2019-08-05 16:01:48 +02:00
Beniamino Galvani
e41bb8fc8e settings: fix memory leak
Fixes: d35d3c468a
(cherry picked from commit 956ffb7e96)
2019-08-05 10:11:08 +02:00
Thomas Haller
8b017dc2fb settings: fix registering AgentManager.RegisterWithCapabilities() twice
Fixes: 297d4985ab
(cherry picked from commit 1634fff1ad)
2019-08-03 18:36:15 +02:00
Thomas Haller
a3f9ab473b wireguard: fix use-after free in _peers_remove()
(cherry picked from commit 85c26341a2)
2019-08-03 12:28:33 +02:00
Thomas Haller
8f2e3d1439 libnm: fix leak in NMSettingWireGuard's update_one_secret()
(cherry picked from commit eea8bbd9ae)
2019-08-03 11:29:41 +02:00
Thomas Haller
79660f1f5b supplicant: mark static arrays as const and static in "nm-supplicant-settings-verify.c"
They should be "static" and only visible to this source file.

Also, they should be "const", that allows the linker to place them
into read-only memory.

(cherry picked from commit 722b167953)
2019-08-02 18:19:49 +02:00
Thomas Haller
da933ffe2a supplicant: don't put binary data in error message for supplicant
For better or worse, the API does not require the value to be a
UTF-8 string. We cannot just concatenate binary to a string.
Instead, backslash escape it with utf8safe-escape.

Also, this will shut up a (wrong) coverity warning at this place.

(cherry picked from commit 55143dad95)
2019-08-02 18:19:49 +02:00
Thomas Haller
d99925a1b0 supplicant: fix nm_supplicant_settings_verify_setting() honoring the string length
We must not just pretend that the value is a NULL terminated string.
That's why we have the length argument.

(cherry picked from commit 9ed26de3da)
2019-08-02 18:19:49 +02:00
Thomas Haller
3ebad253e8 device/bluetooth: explicitly ignore return value of ioctl() in nm_bluez5_dun_cleanup()
Coverity doesn't like us not checking the result.

(cherry picked from commit 526601e4f3)
2019-08-02 18:19:49 +02:00
Thomas Haller
3ebeb43c5f libnm: remove dead code in nm_team_setting_config_get()
I was aware that this code is not reachable. But for consistency, it
seems better to be explict about it (to avoid future bugs when refactoring).

Anyway, Coverity complains about it. So assert instead.

(cherry picked from commit 643bc4ca22)
2019-08-02 18:19:49 +02:00
Thomas Haller
9168dea0da device: trigger a connectivity check when device disconnects
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/219

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/225
(cherry picked from commit 88bcf87ad9)
2019-08-02 17:53:34 +02:00
Thomas Haller
0df7f74c29 core: assert for valid arguments in _addresses_sort_cmp()
Coverity thinks that the arguments could be %NULL. Add an assertion,
hoping to silence coverity.

(cherry picked from commit 1b30797bc1)
2019-08-02 17:13:50 +02:00
Beniamino Galvani
f7b1b1030b tui: newt: remove NULL checks after dereference
priv->start_buttons and priv->end_buttons are initialized at
construction and never changed and so the checks are not needed.

(cherry picked from commit 50ae9c936c)
2019-08-02 16:29:20 +02:00
Beniamino Galvani
fbdfc3f79c n-dhcp4: remove dead code
Reported by coverity.

(cherry picked from commit a32976568c)
2019-08-02 16:29:19 +02:00
Thomas Haller
51b3afa2ee platform/tests: relax assertion for platform signal in test_slave()
Seen on gitlab-ci.

  NMPlatformSignalAssert: ../src/platform/tests/test-link.c:260, test_slave(): failure to accept signal [0,2] times: link-changed-changed ifindex 15 (3 times received)
  ERROR: src/platform/tests/test-link-linux - too few tests run (expected 76, got 6)
  ERROR: src/platform/tests/test-link-linux - exited with status 133 (terminated by signal 5?)

(cherry picked from commit 483de2bb93)
2019-08-02 13:38:32 +02:00
Lubomir Rintel
f2fe6c03ee manager: don't treat the initramfs-configured DHCP connections as generated
These are special -- initramfs configured them and killed dhclient. Bad
things would happen if we let the addresses expire though.

Let's act as if initramfs actually passed the configuration to us.
It actually tries to do so by the means of writing an ifcfg file, but
that one is too broken to be useful, so the ifcfg-rh plugin ignores it.
Notably, it doesn't have the actual addresses or correct BOOTPROTO.
The generated connection is better.

Co-authored-by: Thomas Haller <thaller@redhat.com>
(cherry picked from commit acf3e0092a)
2019-08-02 12:47:45 +02:00
Thomas Haller
115184f5bd adsl: avoid coverity false-positive when using strcpy() for interface name
CID 59391 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
  31. fixed_size_dest: You might overrun the 16-character fixed-size string be.ifspec.spec.ifname by copying priv->nas_ifname without checking the length.

(cherry picked from commit 23fa1b3272)
2019-08-02 11:48:35 +02:00
Thomas Haller
7d603b7e35 libnm: fix parsing invalid "pvid" attribute in GVariant in _nm_utils_bridge_vlans_from_dbus()
Complained by Coverity.

(cherry picked from commit 9f4302e132)
2019-08-02 11:48:35 +02:00
Thomas Haller
6c8f35a267 n-dhcp4: avoid "-Werror=declaration-after-statement" warning with static_assert
When we build n-dhcp4 for NetworkManager we get a compiler warning.
This can also be reproduced by building n-dhcp4 alone:

  $ CFLAGS='-Werror=declaration-after-statement' meson build && ninja -C build
  ...
  [36/47] Compiling C object 'src/25a6634@@ndhcp4-private@sta/n-dhcp4-outgoing.c.o'.
  FAILED: src/25a6634@@ndhcp4-private@sta/n-dhcp4-outgoing.c.o
  ccache cc -Isrc/25a6634@@ndhcp4-private@sta -Isrc -I../src -Isubprojects/c-list/src -I../subprojects/c-list/src -Isubprojects/c-siphash/src -I../subprojects/c-siphash/src -Isubprojects/c-stdaux/src -I../subprojects/c-stdaux/src -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -g -D_GNU_SOURCE -Werror=declaration-after-statement -fPIC -fvisibility=hidden -fno-common -MD -MQ 'src/25a6634@@ndhcp4-private@sta/n-dhcp4-outgoing.c.o' -MF 'src/25a6634@@ndhcp4-private@sta/n-dhcp4-outgoing.c.o.d' -o 'src/25a6634@@ndhcp4-private@sta/n-dhcp4-outgoing.c.o' -c ../src/n-dhcp4-outgoing.c
  ../src/n-dhcp4-outgoing.c: In function ‘n_dhcp4_outgoing_new’:
  ../src/n-dhcp4-outgoing.c:63:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
     63 |         static_assert(N_DHCP4_NETWORK_IP_MINIMUM_MAX_SIZE >= N_DHCP4_OUTGOING_MAX_PHDR +
        |         ^~~~~~~~~~~~~

(cherry picked from commit 9e7ca3e091)
2019-08-02 11:48:35 +02:00
Thomas Haller
368849b589 n-acd: fix leaking socket handle in n_acd_socket_new() when setsockopt() fails
Found by Coverity.

(cherry picked from commit c8cee413dd)
2019-08-02 11:30:30 +02:00
Thomas Haller
b6d9693705 all: merge branch 'th/coverity'
Various fixes for Coverity. For the most part, these are refactorings
to avoid false positive warnings.

(cherry picked from commit d3bd7b9bee)
2019-08-02 11:12:52 +02:00
Thomas Haller
bedafc661a shared: refactor nm_utils_g_slist_strlist_cmp() to avoid dead-code warning from Coverity
Coverity sees that "return 0" cannot be reached. Refactor the code,
to avoid the warning.

(cherry picked from commit 8fb954b81d)
2019-08-02 11:10:51 +02:00
Thomas Haller
14debab83a shared: try avoid coverity warning in _nm_utils_user_data_unpack()
Coverity says

  CID 202453 (#1 of 1): Wrong sizeof argument (SIZEOF_MISMATCH)suspicious_sizeof:
  Passing argument user_data of type gconstpointer and argument (gsize)nargs * 8UL /* sizeof (gconstpointer) */ to function g_slice_free1 is suspicious.

Let's pass instead the "data" pointer. It's the same, but maybe that
avoids the warning.

(cherry picked from commit d76df4c139)
2019-08-02 11:10:51 +02:00
Thomas Haller
709570b8e9 shared: explicitly ignore return value of g_utf8_validate()
Coverity doesn't like us ignoring the return value, although
we really only care about the "p" output pointer.

Try casting the result to (void), maybe that silences Coverity.

(cherry picked from commit e6fa3ce2df)
2019-08-02 11:10:51 +02:00
Thomas Haller
2ecc7e8cb5 initrd: avoid coverity warning in parse_ip() about "Dereference before null check"
get_word() only moves the "argument" pointer forward. It never sets it
to %NULL. Also, above we already dereference argument, so Coverity thinks
that this NULL check indicates a bug.

Drop it to silence Coverity.

(cherry picked from commit 4596d7793c)
2019-08-02 11:10:51 +02:00
Thomas Haller
c347e81a1d libnm/keyfile: silence "Identical code for different branches" complaint in _read_setting_wireguard_peer()
That both branches of the "if" do the same, looks suspicious to Coverity.
Work around it by not doing it.

(cherry picked from commit e001424ae2)
2019-08-02 11:10:51 +02:00
Thomas Haller
e4001e50da device/wireguard: fix explicit_bzero() call on peers buffer in link_config()
Correctly warned by coverity.

(cherry picked from commit 458a2edbb2)
2019-08-02 11:10:51 +02:00
Thomas Haller
fec1c760ec device/adsl: restore brfd value on error in br2684_assign_vcc()
Warned by coverity: we assert above that brfd is -1, so we must always
restore it to -1 in the error case.

Technically, not a problem because socket() is documented to return
only -1 on error already. Apparently coverity does not believe that.

(cherry picked from commit 5b9a848a82)
2019-08-02 11:10:51 +02:00
Thomas Haller
702224ec0b core: assert for valid arguments in sort_captured_addresses() and _addresses_sort_cmp()
Coverity thinks that the arguments could be %NULL. Add an assertion,
hoping to silence coverity.

(cherry picked from commit 8988a12ade)
2019-08-02 11:10:50 +02:00
Thomas Haller
ee153744a9 libnm: avoid NM_CONST_MAX() in enum definition for NMTeamAttribute
This confuses coverity. Just use MAX(). MAX() is usually not preferred
as it evaluates the arguments more than once. But in this case, it is of
course fine.

  CID 202433 (#1 of 1): Unrecoverable parse warning (PARSE_ERROR)1.
  expr_not_constant: expression must have a constant value

(cherry picked from commit 186d559d63)
2019-08-02 11:10:50 +02:00
Thomas Haller
4952e945dc libnm: try to avoid coverity warning in assertion()
Coverity thinks that this could be NULL sometimes. Try to check for that
to shut up the warning.

(cherry picked from commit f61e274df9)
2019-08-02 11:10:50 +02:00
Thomas Haller
12321b1745 libnm: fix assertions in NMSettingVlan's priority API
Most of these functions did not ever return failure. The functions
were assertin that the input was valid (and then returned a special
value). But they did not fail under regular conditions.

Fix the gtk-doc for some of these to not claim to be able to fail.

For some (like nm_setting_vlan_add_priority_str() and
nm_setting_vlan_get_priority()), actually let them fail for valid
input (instead of asserting).

(cherry picked from commit b5793b74ca)
2019-08-02 11:10:50 +02:00
Thomas Haller
96c999e085 cli: fix type for loop variable in _get_fcn_vlan_xgress_priority_map()
Coverity correctly points out that nm_setting_vlan_get_num_priorities() can return
a negative value (-1 on assertion). Handle that by using the right integer type.

(cherry picked from commit af4a41cc4c)
2019-08-02 11:10:50 +02:00
Thomas Haller
650c0cd622 cli: fix dereferncing NULL pointer in parse_passwords() with empty file
Warned by coverity.

(cherry picked from commit ec982ceb8e)
2019-08-02 11:10:50 +02:00
Thomas Haller
ae1f6de899 cli: use gs_free_error in nmcli's "connections.c"
(cherry picked from commit bee0b20e3f)
2019-08-02 11:10:50 +02:00
Thomas Haller
7d5bbe5453 platform: drop checks for failure of nl80211_alloc_msg()
nl80211_alloc_msg() just allocates some memory, using glib's allocators.
Hence it cannot fail, and we don't need to check for that.

Drop the unnecessary %NULL checks.

(cherry picked from commit 990a7bee9d)
2019-08-02 11:10:50 +02:00
Thomas Haller
3c6252f4fd platform: avoid coverity warning about not checking nla_nest_start() result
Usually we check the result of nla_nest_start(). Also, in most cases where this
function would return %NULL, it's an actual bug. That is, because our netlink
message is allocated with a large buffer, and in most cases we append there a well
known, small amount of data.

To make coverity happy, handle the case and assert.

(cherry picked from commit 243458836a)
2019-08-02 11:10:50 +02:00
Thomas Haller
18f7a36ba1 core: fix coverity warning about memset() non-char value in assertion
CID 202432 (#1 of 1): Memset fill truncated (NO_EFFECT)
  bad_memset: Argument -559030611 in memset loses precision in memset(priv->connections_cached_list, -559030611, 8UL * (priv->connections_len + 1U)).

(cherry picked from commit 026739eb9f)
2019-08-02 11:10:50 +02:00
Thomas Haller
291ed80d6c ifcfg-rh: drop g_assert_not_reached() that clearly cannot be reached
Use nm_assert() which is disabled in production builds.

(cherry picked from commit 43575513ca)
2019-08-02 11:10:50 +02:00
Thomas Haller
2953408621 ifcfg-rh: drop unreachable code in make_wpa_setting()
This triggers a coverity warning because we above already
check that not all relevant keys are NULL together.

Work around warning by modifying the code.

(cherry picked from commit 210d7eb528)
2019-08-02 11:10:50 +02:00
Thomas Haller
40c5b79e36 core/trivial: fix whitespace
(cherry picked from commit 2ea3c23723)
2019-08-02 11:10:50 +02:00
Thomas Haller
f804bc7007 shared: fix non-serious bug with bogus condition in assertion in nm_key_file_db_ref()
(cherry picked from commit 9a229241f9)
2019-08-01 17:25:37 +02:00
Thomas Haller
d84d1db39e core/lldp: minor cleanup in _lldp_attr_*()
- use nm_g_variant_unref_floating()

- rename _lldp_attr_take_str_ptr() to _lldp_attr_set_str_take().
  The new name has the same "_lldp_attr_set_" prefix as other setters.
  Also, with the previous name it is unclear why it takes a "str-ptr".

- setting the same attribute multiple times, ignores all but the first
  value. Avoid cloning the string in that case, and explicitly choose
  the set or take function.

(cherry picked from commit 0fbb54839e)
2019-08-01 15:20:57 +02:00
Thomas Haller
273f0b5416 core/lldp: fix memleak in _lldp_attr_take_str_ptr()
Valgrind complains:

  ==26355== 32 bytes in 2 blocks are definitely lost in loss record 2,829 of 6,716
  ==26355==    at 0x4838748: malloc (vg_replace_malloc.c:308)
  ==26355==    by 0x483AD63: realloc (vg_replace_malloc.c:836)
  ==26355==    by 0x4F6AD4F: g_realloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F87B33: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F87B96: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x2D66E1: nm_utils_buf_utf8safe_escape (nm-shared-utils.c:1911)
  ==26355==    by 0x4113B0: lldp_neighbor_new (nm-lldp-listener.c:676)
  ==26355==    by 0x412788: process_lldp_neighbor (nm-lldp-listener.c:882)
  ==26355==    by 0x4135CF: lldp_event_handler (nm-lldp-listener.c:931)
  ==26355==    by 0x422CDB: lldp_callback (sd-lldp.c:50)
  ==26355==    by 0x4235F9: lldp_add_neighbor (sd-lldp.c:166)
  ==26355==    by 0x423679: lldp_handle_datagram (sd-lldp.c:189)
  ==26355==    by 0x423C8B: lldp_receive_datagram (sd-lldp.c:235)
  ==26355==    by 0x2F887A: source_dispatch (sd-event.c:2832)
  ==26355==    by 0x2FAD43: sd_event_dispatch (sd-event.c:3245)
  ==26355==    by 0x2D9237: event_dispatch (nm-sd.c:51)
  ==26355==    by 0x4F64EDC: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F6526F: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F655A2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x140932: main (main.c:465)
  ==26355==

(cherry picked from commit ece270ea5f)
2019-08-01 15:20:57 +02:00
Beniamino Galvani
0581a53a46 merge: branch 'bg/ovs-restart-part2-rh1733709'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/216

https://bugzilla.redhat.com/show_bug.cgi?id=1733709
(cherry picked from commit 5f668b81d3)
2019-08-01 09:31:52 +02:00