[systemd-commits] 2 commits - src/libudev src/shared

Tom Gundersen tomegun at kemper.freedesktop.org
Thu Sep 18 04:49:04 PDT 2014


 src/libudev/libudev-monitor.c |    5 ++++-
 src/shared/conf-parser.h      |   12 +++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

New commits:
commit 77c10205bb337585c320e91af4b416f2dcc6faba
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Sep 18 13:47:00 2014 +0200

    shared: conf-parser - don't leak memory on error in DEFINE_CONFIG_PARSE_ENUMV
    
    Found by Coverity. Fixes CID #1237746.

diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 9418515..62f2a01 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -169,7 +169,8 @@ int log_syntax_internal(const char *unit, int level,
                      void *data,                                               \
                      void *userdata) {                                         \
                                                                                \
-                type **enums = data, *xs, x, *ys;                              \
+                type **enums = data, x, *ys;                                   \
+                _cleanup_free_ type *xs = NULL;                                \
                 const char *word, *state;                                      \
                 size_t l, i = 0;                                               \
                                                                                \
@@ -186,6 +187,7 @@ int log_syntax_internal(const char *unit, int level,
                                                                                \
                 FOREACH_WORD(word, l, rvalue, state) {                         \
                         _cleanup_free_ char *en = NULL;                        \
+                        type *new_xs;                                          \
                                                                                \
                         en = strndup(word, l);                                 \
                         if (!en)                                               \
@@ -211,8 +213,10 @@ int log_syntax_internal(const char *unit, int level,
                                 continue;                                      \
                                                                                \
                         *(xs + i) = x;                                         \
-                        xs = realloc(xs, (++i + 1) * sizeof(type));            \
-                        if (!xs)                                               \
+                        new_xs = realloc(xs, (++i + 1) * sizeof(type));        \
+                        if (new_xs)                                            \
+                                xs = new_xs;                                   \
+                        else                                                   \
                                 return -ENOMEM;                                \
                                                                                \
                         *(xs + i) = invalid;                                   \
@@ -220,5 +224,7 @@ int log_syntax_internal(const char *unit, int level,
                                                                                \
                 free(*enums);                                                  \
                 *enums = xs;                                                   \
+                xs = NULL;                                                     \
+                                                                               \
                 return 0;                                                      \
         }

commit 9dedfe7f667a8cb22ba85d0223556c69c4fd0e9a
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Sep 18 09:20:46 2014 +0200

    libudev: monitor - warn if we fail to request SO_PASSCRED
    
    The function still succeeds, so there is no functional change. This fixes CID #996288.

diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 186e5e1..59698b8 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -412,7 +412,10 @@ _public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
         }
 
         /* enable receiving of sender credentials */
-        setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+        err = setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+        if (err < 0)
+                udev_err(udev_monitor->udev, "setting SO_PASSCRED failed: %m\n");
+
         return 0;
 }
 



More information about the systemd-commits mailing list