Commit Graph

7 Commits

Author SHA1 Message Date
Lubomir Rintel
ee916a1e9e all: fix -Wcast-function-type warnings
GCC 8.0's -Wcast-function-type objects casting function pointers to ones
with incompatible prototypes. Sometimes we do that on purpose though.

Notably, the g_source_set_callback()'s func argument can point to functions
of various prototypes. Also, libnm-glib/nm-remote-connection is perhaps
just not worth reworking, that would just be a waste of time.

A cast to void(*)(void) avoids the GCC warning, let's use it.
2018-02-08 17:11:46 +01:00
Thomas Haller
c15eae92c0 libnm: don't cunescape \x00 encoding in nm_udev_utils_property_decode()
UDev never creates such invalid escape sequences. Anyway,
we cannot accept a NUL character at this point. Just take
the ill escape verbatim -- it should never happen anyway.
2017-05-19 09:46:08 +02:00
Thomas Haller
9594ee6e69 libnm: fix unterminated NUL string when parsing UDev properties
This can result in trailing garbage (which fails UTF-8 validation
checks) or even worse, in read-out-of-bounds.

Fixes: 6808bf8195

https://bugzilla.redhat.com/show_bug.cgi?id=1443114
https://bugzilla.redhat.com/show_bug.cgi?id=1451160
https://bugzilla.redhat.com/show_bug.cgi?id=1451286
2017-05-19 09:46:08 +02:00
Thomas Haller
0893c3756e utils: fix maybe-uninitialized in "nm-udev-utils.c"
CC       shared/nm-utils/libnm_core_libnm_core_la-nm-udev-utils.lo
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:29,
                     from ./shared/nm-default.h:178,
                     from shared/nm-utils/nm-udev-utils.c:21:
    shared/nm-utils/nm-udev-utils.c: In function ‘nm_udev_client_enumerate_new’:
    ./shared/nm-utils/gsystem-local-alloc.h:53:50: error: ‘to_free’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
                                                      ^~~~~~
    shared/nm-utils/nm-udev-utils.c:147:18: note: ‘to_free’ was declared here
        gs_free char *to_free;
                      ^~~~~~~
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:29,
                     from ./shared/nm-default.h:178,
                     from shared/nm-utils/nm-udev-utils.c:21:
    shared/nm-utils/nm-udev-utils.c: In function ‘nm_udev_client_new’:
    ./shared/nm-utils/gsystem-local-alloc.h:53:50: error: ‘to_free’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
                                                      ^~~~~~
    shared/nm-utils/nm-udev-utils.c:243:20: note: ‘to_free’ was declared here
          gs_free char *to_free;
                        ^~~~~~~

Fixes: e32839838e
2017-05-10 15:34:23 +02:00
Thomas Haller
6808bf8195 udev: add and use nm_udev_utils_property_decode() function
DRY.
2017-03-22 12:41:06 +01:00
Thomas Haller
c48c13b8e5 udev: only create monitor in NMUdevClient when needed
GUdevClient always creates a monitor instance, even if there are no subsystems
or handlers defined. Hence the first iteration of NMUdevClient did that as
well.

I think that can be avoided however. We only need a monitor when there is
a event handler subscribed. Contrary to GUdevClient, we know that from the
very beginning.
2017-03-22 12:41:06 +01:00
Thomas Haller
e32839838e udev: drop libgudev in favor of libudev
libgudev is just a wrapper around libudev. We can
use libudev directly and drop the dependency for
libgudev.
2017-03-22 12:41:06 +01:00