]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/storage/rbd.c
secure coding: #2 strcpy => strlcpy
[mirror_lxc.git] / src / lxc / storage / rbd.c
index 570de53daa2e2fc6bff71e7cf251761bcbcad64c..10ad892a06203bace03f836fbdf40118a2969d6d 100644 (file)
 #include "storage_utils.h"
 #include "utils.h"
 
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
 lxc_log_define(rbd, lxc);
 
 struct rbd_args {
@@ -193,6 +197,7 @@ int rbd_destroy(struct lxc_storage *orig)
        char *rbdfullname;
        char cmd_output[MAXPATHLEN];
        struct rbd_args args = {0};
+       size_t len;
 
        src = lxc_storage_get_path(orig->src, orig->type);
        if (file_exists(src)) {
@@ -206,9 +211,11 @@ int rbd_destroy(struct lxc_storage *orig)
                }
        }
 
-       rbdfullname = alloca(strlen(src) - 8);
-       strcpy(rbdfullname, &src[9]);
+       len = strlen(src);
+       rbdfullname = alloca(len - 8);
+       (void)strlcpy(rbdfullname, &src[9], len - 8);
        args.rbd_name = rbdfullname;
+
        ret = run_command(cmd_output, sizeof(cmd_output),
                        rbd_delete_wrapper, (void *)&args);
        if (ret < 0) {