]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Fix strlcat's return value checks
authorAriel Miculas <amiculas@cisco.com>
Tue, 7 Feb 2023 11:10:50 +0000 (13:10 +0200)
committerAriel Miculas <amiculas@cisco.com>
Tue, 7 Feb 2023 11:52:31 +0000 (13:52 +0200)
Alternatively we could have used safe_strlcat, but it's not used
anywhere and there's also no safe_strlcpy

Signed-off-by: Ariel Miculas <amiculas@cisco.com>
src/lxc/conf.c

index 9158713c7879fe8ff885dc112395fffc6de491ee..d2ab8ceda20aa11038aff356c5b142f1cf06483f 100644 (file)
@@ -2212,7 +2212,7 @@ static int lxc_setup_console(const struct lxc_handler *handler,
 
 static int parse_mntopt(char *opt, unsigned long *flags, char **data, size_t size)
 {
-       ssize_t ret;
+       size_t ret;
 
        /* If '=' is contained in opt, the option must go into data. */
        if (!strchr(opt, '=')) {
@@ -2236,12 +2236,12 @@ static int parse_mntopt(char *opt, unsigned long *flags, char **data, size_t siz
 
        if (strlen(*data)) {
                ret = strlcat(*data, ",", size);
-               if (ret < 0)
+               if (ret >= size)
                        return log_error_errno(ret, errno, "Failed to append \",\" to %s", *data);
        }
 
        ret = strlcat(*data, opt, size);
-       if (ret < 0)
+       if (ret >= size)
                return log_error_errno(ret, errno, "Failed to append \"%s\" to %s", opt, *data);
 
        return 0;