]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: fix integer comparisons
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Sep 2021 07:34:59 +0000 (09:34 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Sep 2021 07:47:34 +0000 (09:47 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 0e9cbcec64bfa99282b4f3e12396f3ec74157ac0..3103263b32258e38b978a8a6cf3ffa6d0caa802c 100644 (file)
@@ -163,7 +163,7 @@ int prepare_cgroup_fd(const struct cgroup_ops *ops, struct cgroup_fd *fd, bool l
         * The client requested that the controller must be in a specific
         * cgroup version.
         */
-       if (fd->type != 0 && fd->type != h->fs_type)
+       if (fd->type != 0 && (cgroupfs_type_magic_t)fd->type != h->fs_type)
                return ret_errno(EINVAL);
 
        if (limit)
@@ -2132,7 +2132,7 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
                 * that a short write would cause a buffer overrun. So be on
                 * the safe side.
                 */
-               if (ret < STRLITERALLEN(".lxc-/cgroup.procs"))
+               if ((size_t)ret < STRLITERALLEN(".lxc-/cgroup.procs"))
                        return log_error_errno(-EINVAL, EINVAL, "Unexpected short write would cause buffer-overrun");
 
                slash += (ret - STRLITERALLEN("/cgroup.procs"));
@@ -2208,11 +2208,11 @@ static int cgroup_attach_move_into_leaf(const struct lxc_conf *conf,
        pidstr_len = sprintf(pidstr, INT64_FMT, (int64_t)pid);
 
        ret = lxc_write_nointr(target_fd0, pidstr, pidstr_len);
-       if (ret > 0 && ret == pidstr_len)
+       if (ret > 0 && (size_t)ret == pidstr_len)
                return log_debug(0, "Moved process into target cgroup via fd %d", target_fd0);
 
        ret = lxc_write_nointr(target_fd1, pidstr, pidstr_len);
-       if (ret > 0 && ret == pidstr_len)
+       if (ret > 0 && (size_t)ret == pidstr_len)
                return log_debug(0, "Moved process into target cgroup via fd %d", target_fd1);
 
        return log_debug_errno(-1, errno, "Failed to move process into target cgroup via fd %d and %d",
@@ -2437,7 +2437,8 @@ static int device_cgroup_parse_access(struct device_item *device, const char *va
 static int device_cgroup_rule_parse(struct device_item *device, const char *key,
                                    const char *val)
 {
-       int count, ret;
+       size_t count;
+       int ret;
        char temp[50];
 
        if (strequal("devices.allow", key))