Commit 1e065898 authored by Kees Cook's avatar Kees Cook

um: Convert strscpy() usage to 2-argument style

The ARCH=um build has its own idea about strscpy()'s definition. Adjust
the callers to remove the redundant sizeof() arguments ahead of treewide
changes, since it needs a manual adjustment for the newly named
sized_strscpy() export.

Cc: Richard Weinberger <richard@nod.at>
Cc: linux-um@lists.infradead.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 8366d124
...@@ -265,7 +265,7 @@ static void uml_net_poll_controller(struct net_device *dev) ...@@ -265,7 +265,7 @@ static void uml_net_poll_controller(struct net_device *dev)
static void uml_net_get_drvinfo(struct net_device *dev, static void uml_net_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
strscpy(info->driver, DRIVER_NAME, sizeof(info->driver)); strscpy(info->driver, DRIVER_NAME);
} }
static const struct ethtool_ops uml_net_ethtool_ops = { static const struct ethtool_ops uml_net_ethtool_ops = {
......
...@@ -1373,7 +1373,7 @@ static void vector_net_poll_controller(struct net_device *dev) ...@@ -1373,7 +1373,7 @@ static void vector_net_poll_controller(struct net_device *dev)
static void vector_net_get_drvinfo(struct net_device *dev, static void vector_net_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
strscpy(info->driver, DRIVER_NAME, sizeof(info->driver)); strscpy(info->driver, DRIVER_NAME);
} }
static int vector_net_load_bpf_flash(struct net_device *dev, static int vector_net_load_bpf_flash(struct net_device *dev,
......
...@@ -141,7 +141,7 @@ static int create_tap_fd(char *iface) ...@@ -141,7 +141,7 @@ static int create_tap_fd(char *iface)
} }
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR; ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
strscpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); strscpy(ifr.ifr_name, iface);
err = ioctl(fd, TUNSETIFF, (void *) &ifr); err = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (err != 0) { if (err != 0) {
...@@ -171,7 +171,7 @@ static int create_raw_fd(char *iface, int flags, int proto) ...@@ -171,7 +171,7 @@ static int create_raw_fd(char *iface, int flags, int proto)
goto raw_fd_cleanup; goto raw_fd_cleanup;
} }
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
strscpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); strscpy(ifr.ifr_name, iface);
if (ioctl(fd, SIOCGIFINDEX, (void *) &ifr) < 0) { if (ioctl(fd, SIOCGIFINDEX, (void *) &ifr) < 0) {
err = -errno; err = -errno;
goto raw_fd_cleanup; goto raw_fd_cleanup;
......
...@@ -52,7 +52,7 @@ static inline int printk(const char *fmt, ...) ...@@ -52,7 +52,7 @@ static inline int printk(const char *fmt, ...)
extern int in_aton(char *str); extern int in_aton(char *str);
extern size_t strlcat(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t);
extern size_t sized_strscpy(char *, const char *, size_t); extern size_t sized_strscpy(char *, const char *, size_t);
#define strscpy(dst, src, size) sized_strscpy(dst, src, size) #define strscpy(dst, src) sized_strscpy(dst, src, sizeof(dst))
/* Copied from linux/compiler-gcc.h since we can't include it directly */ /* Copied from linux/compiler-gcc.h since we can't include it directly */
#define barrier() __asm__ __volatile__("": : :"memory") #define barrier() __asm__ __volatile__("": : :"memory")
......
...@@ -105,7 +105,7 @@ static int etap_tramp(char *dev, char *gate, int control_me, ...@@ -105,7 +105,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
sprintf(data_fd_buf, "%d", data_remote); sprintf(data_fd_buf, "%d", data_remote);
sprintf(version_buf, "%d", UML_NET_VERSION); sprintf(version_buf, "%d", UML_NET_VERSION);
if (gate != NULL) { if (gate != NULL) {
strscpy(gate_buf, gate, sizeof(gate_buf)); strscpy(gate_buf, gate);
args = setup_args; args = setup_args;
} }
else args = nosetup_args; else args = nosetup_args;
......
...@@ -146,7 +146,7 @@ static int tuntap_open(void *data) ...@@ -146,7 +146,7 @@ static int tuntap_open(void *data)
} }
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI; ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
strscpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); strscpy(ifr.ifr_name, pri->dev_name);
if (ioctl(pri->fd, TUNSETIFF, &ifr) < 0) { if (ioctl(pri->fd, TUNSETIFF, &ifr) < 0) {
err = -errno; err = -errno;
printk(UM_KERN_ERR "TUNSETIFF failed, errno = %d\n", printk(UM_KERN_ERR "TUNSETIFF failed, errno = %d\n",
......
...@@ -40,7 +40,7 @@ static int __init make_uml_dir(void) ...@@ -40,7 +40,7 @@ static int __init make_uml_dir(void)
__func__); __func__);
goto err; goto err;
} }
strscpy(dir, home, sizeof(dir)); strscpy(dir, home);
uml_dir++; uml_dir++;
} }
strlcat(dir, uml_dir, sizeof(dir)); strlcat(dir, uml_dir, sizeof(dir));
...@@ -243,7 +243,7 @@ int __init set_umid(char *name) ...@@ -243,7 +243,7 @@ int __init set_umid(char *name)
if (strlen(name) > UMID_LEN - 1) if (strlen(name) > UMID_LEN - 1)
return -E2BIG; return -E2BIG;
strscpy(umid, name, sizeof(umid)); strscpy(umid, name);
return 0; return 0;
} }
...@@ -262,7 +262,7 @@ static int __init make_umid(void) ...@@ -262,7 +262,7 @@ static int __init make_umid(void)
make_uml_dir(); make_uml_dir();
if (*umid == '\0') { if (*umid == '\0') {
strscpy(tmp, uml_dir, sizeof(tmp)); strscpy(tmp, uml_dir);
strlcat(tmp, "XXXXXX", sizeof(tmp)); strlcat(tmp, "XXXXXX", sizeof(tmp));
fd = mkstemp(tmp); fd = mkstemp(tmp);
if (fd < 0) { if (fd < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment