#include <sys/personality.h>
#endif
+#ifndef HAVE_STRLCAT
+#include "include/strlcat.h"
+#endif
+
#if IS_BIONIC
#include <../include/lxcmntent.h>
#else
static bool append_ttyname(char **pp, char *name)
{
char *p;
+ size_t size;
if (!*pp) {
*pp = malloc(strlen(name) + strlen("container_ttys=") + 1);
return true;
}
- p = realloc(*pp, strlen(*pp) + strlen(name) + 2);
+ size = strlen(*pp) + strlen(name) + 2;
+ p = realloc(*pp, size);
if (!p)
return false;
*pp = p;
- strncat(p, " ", 1);
- strncat(p, name, strlen(name));
+ (void)strlcat(p, " ", size);
+ (void)strlcat(p, name, size);
return true;
}
static void parse_mntopt(char *opt, unsigned long *flags, char **data, size_t size)
{
struct mount_opt *mo;
- size_t cursize;
/* If opt is found in mount_opt, set or clear flags.
* Otherwise append it to data. */
}
}
- cursize = strlen(*data);
- if (cursize)
- cursize += 1;
+ if (strlen(*data))
+ (void)strlcat(*data, ",", size);
- if (size - cursize > 1) {
- if (cursize)
- strncat(*data, ",", 1);
-
- strncat(*data, opt, size - cursize - 1);
- }
+ (void)strlcat(*data, opt, size);
}
int parse_mntopts(const char *mntopts, unsigned long *mntflags, char **mntdata)