#include <linux/memcontrol.h>
#include <linux/mm_inline.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/random.h>
#include <linux/reboot.h>
#include <linux/notifier.h>
}
if (apv >= 88)
- strcpy(p->verify_alg, nc->verify_alg);
+ strscpy(p->verify_alg, nc->verify_alg);
if (apv >= 89)
- strcpy(p->csums_alg, nc->csums_alg);
+ strscpy(p->csums_alg, nc->csums_alg);
rcu_read_unlock();
return drbd_send_command(peer_device, sock, cmd, size, NULL, 0);
struct drbd_socket *sock;
struct p_protocol *p;
struct net_conf *nc;
+ size_t integrity_alg_len;
int size, cf;
sock = &connection->data;
}
size = sizeof(*p);
- if (connection->agreed_pro_version >= 87)
- size += strlen(nc->integrity_alg) + 1;
+ if (connection->agreed_pro_version >= 87) {
+ integrity_alg_len = strlen(nc->integrity_alg) + 1;
+ size += integrity_alg_len;
+ }
p->protocol = cpu_to_be32(nc->wire_protocol);
p->after_sb_0p = cpu_to_be32(nc->after_sb_0p);
p->conn_flags = cpu_to_be32(cf);
if (connection->agreed_pro_version >= 87)
- strcpy(p->integrity_alg, nc->integrity_alg);
+ strscpy(p->integrity_alg, nc->integrity_alg, integrity_alg_len);
rcu_read_unlock();
return __conn_send_command(connection, sock, cmd, size, NULL, 0);
*new_net_conf = *old_net_conf;
if (verify_tfm) {
- strcpy(new_net_conf->verify_alg, p->verify_alg);
+ strscpy(new_net_conf->verify_alg, p->verify_alg);
new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1;
crypto_free_shash(peer_device->connection->verify_tfm);
peer_device->connection->verify_tfm = verify_tfm;
drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg);
}
if (csums_tfm) {
- strcpy(new_net_conf->csums_alg, p->csums_alg);
+ strscpy(new_net_conf->csums_alg, p->csums_alg);
new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1;
crypto_free_shash(peer_device->connection->csums_tfm);
peer_device->connection->csums_tfm = csums_tfm;