#include "parse.h"
#include "utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
#define usernic_debug_stream(stream, format, ...) \
do { \
fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \
{
int ret;
char *p;
+ size_t len;
- p = alloca(strlen(fnam) + 1);
- strcpy(p, fnam);
+ len = strlen(fnam);
+ p = alloca(len + 1);
+ (void)strlcpy(p, fnam, len + 1);
fnam = p;
p = p + 1;
#include <sys/personality.h>
#endif
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
lxc_log_define(lxc_confile, lxc);
#define lxc_config_define(name) \
return -1;
}
- strcpy(utsname->nodename, value);
+ (void)strlcpy(utsname->nodename, value, sizeof(utsname->nodename));
free(lxc_conf->utsname);
lxc_conf->utsname = utsname;
#include "initutils.h"
#include "log.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
lxc_log_define(lxc_initutils, lxc);
static char *copy_global_config_value(char *p)
if (len < 1)
return NULL;
+
if (p[len-1] == '\n') {
p[len-1] = '\0';
len--;
}
- retbuf = malloc(len+1);
+
+ retbuf = malloc(len + 1);
if (!retbuf)
return NULL;
- strcpy(retbuf, p);
+
+ (void)strlcpy(retbuf, p, len + 1);
return retbuf;
}
ret = prctl(PR_SET_MM, PR_SET_MM_MAP, (long) &prctl_map, sizeof(prctl_map), 0);
if (ret == 0)
- strcpy((char*)arg_start, title);
+ (void)strlcpy((char*)arg_start, title, len);
else
INFO("setting cmdline failed - %s", strerror(errno));
#include "utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
#define pam_cgfs_debug_stream(stream, format, ...) \
do { \
fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \
return NULL;
if (use_as_prefix)
- strcpy(result, sep);
+ (void)strlcpy(result, sep, (result_len + 1) * sizeof(char));
+
for (p = (char **)parts; *p; p++) {
if (p > (char **)parts)
strcat(result, sep);
#include "storage_utils.h"
#include "utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
lxc_log_define(nbd, lxc);
struct nbd_attach_data {
bool attach_nbd(char *src, struct lxc_conf *conf)
{
- char *orig = alloca(strlen(src)+1), *p, path[50];
+ char *orig, *p, path[50];
int i = 0;
+ size_t len;
+
+ len = strlen(src);
+ orig = alloca(len + 1);
+ (void)strlcpy(orig, src, len + 1);
- strcpy(orig, src);
/* if path is followed by a partition, drop that for now */
p = strchr(orig, ':');
if (p)
#include "storage_utils.h"
#include "utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
lxc_log_define(rbd, lxc);
struct rbd_args {
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)) {
}
}
- 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) {
#include "utils.h"
#include "zfs.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
#ifndef BLKGETSIZE64
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#endif
if (strchr(type, ',')) {
char *dup, *token;
char *saveptr = NULL;
+ size_t len;
+
+ len = strlen(type);
+ dup = alloca(len + 1);
+ (void)strlcpy(dup, type, len + 1);
- dup = alloca(strlen(type) + 1);
- strcpy(dup, type);
for (token = strtok_r(dup, ",", &saveptr); token;
token = strtok_r(NULL, ",", &saveptr)) {
bdev = do_storage_create(dest, token, cname, specs);
#include "arguments.h"
#include "tool_utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
int lxc_fill_elevated_privileges(char *flaglist, int *flags)
{
char *token, *saveptr = NULL;
char **tmp = NULL, **result = NULL;
size_t result_capacity = 0;
size_t result_count = 0;
+ size_t len;
int r, saved_errno;
if (!string)
return calloc(1, sizeof(char *));
- str = alloca(strlen(string) + 1);
- strcpy(str, string);
+ len = strlen(string);
+ str = alloca(len + 1);
+ (void)strlcpy(str, string, len + 1);
+
for (; (token = strtok_r(str, sep, &saveptr)); str = NULL) {
r = lxc_grow_array((void ***)&result, &result_capacity, result_count + 1, 16);
if (r < 0)
return NULL;
if (use_as_prefix)
- strcpy(result, sep);
+ (void)strlcpy(result, sep, result_len + 1);
+
for (p = (char **)parts; *p; p++) {
if (p > (char **)parts)
strcat(result, sep);
size_t result_count = 0;
int r, saved_errno;
size_t i = 0;
+ size_t len;
if (!string)
return calloc(1, sizeof(char *));
- str = alloca(strlen(string)+1);
- strcpy(str, string);
+ len = strlen(string);
+ str = alloca(len + 1);
+ (void)strlcpy(str, string, len + 1);
+
for (; (token = strtok_r(str, sep, &saveptr)); str = NULL) {
while (token[0] == ' ' || token[0] == '\t')
token++;
#include "parse.h"
#include "utils.h"
+#ifndef HAVE_STRLCPY
+#include "include/strlcpy.h"
+#endif
+
#ifndef O_PATH
#define O_PATH 010000000
#endif
return NULL;
if (use_as_prefix)
- strcpy(result, sep);
+ (void)strlcpy(result, sep, result_len + 1);
+
for (p = (char **)parts; *p; p++) {
if (p > (char **)parts)
strcat(result, sep);
{
char *token, *str, *saveptr = NULL;
char sep[2] = { _sep, '\0' };
+ size_t len;
if (!haystack || !needle)
return 0;
- str = alloca(strlen(haystack)+1);
- strcpy(str, haystack);
+ len = strlen(haystack);
+ str = alloca(len + 1);
+ (void)strlcpy(str, haystack, len + 1);
+
for (; (token = strtok_r(str, sep, &saveptr)); str = NULL) {
if (strcmp(needle, token) == 0)
return 1;
size_t result_capacity = 0;
size_t result_count = 0;
int r, saved_errno;
+ size_t len;
if (!string)
return calloc(1, sizeof(char *));
- str = alloca(strlen(string) + 1);
- strcpy(str, string);
+ len = strlen(string);
+ str = alloca(len + 1);
+ (void)strlcpy(str, string, len + 1);
+
for (; (token = strtok_r(str, sep, &saveptr)); str = NULL) {
r = lxc_grow_array((void ***)&result, &result_capacity, result_count + 1, 16);
if (r < 0)
size_t result_count = 0;
int r, saved_errno;
size_t i = 0;
+ size_t len;
if (!string)
return calloc(1, sizeof(char *));
- str = alloca(strlen(string)+1);
- strcpy(str, string);
+ len = strlen(string);
+ str = alloca(len + 1);
+ (void)strlcpy(str, string, len + 1);
+
for (; (token = strtok_r(str, sep, &saveptr)); str = NULL) {
while (token[0] == ' ' || token[0] == '\t')
token++;