anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0336-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch

84b277
From aab1a9e316bfa55ab41ecad102c90c6b7eeac52e Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Tue, 18 Mar 2014 04:06:36 +0100
84b277
Subject: [PATCH] cgroup: it's not OK to invoke alloca() in loops
84b277
84b277
(cherry-picked from a641dcd9bf05418d6a6c165e1c0cff615b4a0f47)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/core/mount-setup.c | 20 ++++++++++++++------
84b277
 1 file changed, 14 insertions(+), 6 deletions(-)
84b277
84b277
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
84b277
index 4359f59..679f289 100644
84b277
--- a/src/core/mount-setup.c
84b277
+++ b/src/core/mount-setup.c
84b277
@@ -210,10 +210,10 @@ int mount_setup_early(void) {
84b277
 }
84b277
 
84b277
 int mount_cgroup_controllers(char ***join_controllers) {
84b277
-        int r;
84b277
-        char buf[LINE_MAX];
84b277
         _cleanup_set_free_free_ Set *controllers = NULL;
84b277
         _cleanup_fclose_ FILE *f;
84b277
+        char buf[LINE_MAX];
84b277
+        int r;
84b277
 
84b277
         /* Mount all available cgroup controllers that are built into the kernel. */
84b277
 
84b277
@@ -256,6 +256,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
84b277
         }
84b277
 
84b277
         for (;;) {
84b277
+                _cleanup_free_ char *options = NULL, *controller = NULL, *where = NULL;
84b277
                 MountPoint p = {
84b277
                         .what = "cgroup",
84b277
                         .type = "cgroup",
84b277
@@ -263,7 +264,6 @@ int mount_cgroup_controllers(char ***join_controllers) {
84b277
                         .mode = MNT_IN_CONTAINER,
84b277
                 };
84b277
                 char ***k = NULL;
84b277
-                _cleanup_free_ char *options = NULL, *controller;
84b277
 
84b277
                 controller = set_steal_first(controllers);
84b277
                 if (!controller)
84b277
@@ -280,7 +280,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
84b277
                         for (i = *k, j = *k; *i; i++) {
84b277
 
84b277
                                 if (!streq(*i, controller)) {
84b277
-                                        char _cleanup_free_ *t;
84b277
+                                        _cleanup_free_ char *t;
84b277
 
84b277
                                         t = set_remove(controllers, *i);
84b277
                                         if (!t) {
84b277
@@ -302,7 +302,11 @@ int mount_cgroup_controllers(char ***join_controllers) {
84b277
                         controller = NULL;
84b277
                 }
84b277
 
84b277
-                p.where = strappenda("/sys/fs/cgroup/", options);
84b277
+                where = strappend("/sys/fs/cgroup/", options);
84b277
+                if (!where)
84b277
+                        return log_oom();
84b277
+
84b277
+                p.where = where;
84b277
                 p.options = options;
84b277
 
84b277
                 r = mount_one(&p, true);
84b277
@@ -313,7 +317,11 @@ int mount_cgroup_controllers(char ***join_controllers) {
84b277
                         char **i;
84b277
 
84b277
                         for (i = *k; *i; i++) {
84b277
-                                char *t = strappenda("/sys/fs/cgroup/", *i);
84b277
+                                _cleanup_free_ char *t = NULL;
84b277
+
84b277
+                                t = strappend("/sys/fs/cgroup/", *i);
84b277
+                                if (!t)
84b277
+                                        return log_oom();
84b277
 
84b277
                                 r = symlink(options, t);
84b277
                                 if (r < 0 && errno != EEXIST) {