]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/confile.c
secure coding: #2 strcpy => strlcpy
[mirror_lxc.git] / src / lxc / confile.c
index 558e32e8c9b147427b61f46e3199bfc1c330f585..d019c898484ff9843d70440b3795ae2c02c0b80a 100644 (file)
 #include <sys/personality.h>
 #endif
 
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
 lxc_log_define(lxc_confile, lxc);
 
 #define lxc_config_define(name)                                                \
@@ -628,8 +632,12 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
        /* No prefix specified, determine it from the network class. */
        if (prefix) {
                ret = lxc_safe_uint(prefix, &inetdev->prefix);
-               if (ret < 0)
+               if (ret < 0) {
+                       free(inetdev);
+                       free(list);
+                       free(addr);
                        return -1;
+               }
        } else {
                inetdev->prefix = config_ip_prefix(&inetdev->addr);
        }
@@ -2076,8 +2084,6 @@ static int do_includedir(const char *dirp, struct lxc_conf *lxc_conf)
 
        while ((direntp = readdir(dir))) {
                const char *fnam;
-               if (!direntp)
-                       break;
 
                fnam = direntp->d_name;
                if (!strcmp(fnam, "."))
@@ -2193,7 +2199,7 @@ static int set_config_uts_name(const char *key, const char *value,
                return -1;
        }
 
-       strcpy(utsname->nodename, value);
+       (void)strlcpy(utsname->nodename, value, sizeof(utsname->nodename));
        free(lxc_conf->utsname);
        lxc_conf->utsname = utsname;