[systemd-commits] src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Mon Nov 25 14:39:28 PST 2013


 src/shared/conf-parser.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 4ae7885c2c4d89e1149c3fb186a4fe3b49787cc7
Author: Yin Kangkai <kangkai.yin at intel.com>
Date:   Mon Nov 25 23:14:46 2013 +0800

    conf-parser: fix memory realloc error
    
    Otherwise there is some memory corruption and undefined behavior,
    e.g., in my case systemd-udev was always aborted at the
    _cleanup_freep_ around that code blocks.

diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 42602b3..2d5aa31 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -202,7 +202,7 @@ int log_syntax_internal(const char *unit, int level,
                                 continue;                                      \
                                                                                \
                         *(xs + i) = x;                                         \
-                        xs = realloc(xs, ++i + 1);                             \
+                        xs = realloc(xs, (++i + 1) * sizeof(type));            \
                         if (!xs)                                               \
                                 return -ENOMEM;                                \
                         *(xs + i) = invalid;                                   \



More information about the systemd-commits mailing list