summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelos <angelos@openbsd.org>2000-09-21 01:34:19 +0000
committerangelos <angelos@openbsd.org>2000-09-21 01:34:19 +0000
commite38a517e40afdd197f094668dc79f8668ca01d99 (patch)
tree667a689f1bdc59f91208d0871331268102e5320d
parentformatting; from NetBSD (diff)
downloadwireguard-openbsd-e38a517e40afdd197f094668dc79f8668ca01d99.tar.xz
wireguard-openbsd-e38a517e40afdd197f094668dc79f8668ca01d99.zip
Allocate memory for srcid/dstid.
-rw-r--r--sbin/ipsecadm/ipsecadm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sbin/ipsecadm/ipsecadm.c b/sbin/ipsecadm/ipsecadm.c
index 73082df331d..6eb456f190b 100644
--- a/sbin/ipsecadm/ipsecadm.c
+++ b/sbin/ipsecadm/ipsecadm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsecadm.c,v 1.41 2000/09/20 21:28:23 angelos Exp $ */
+/* $OpenBSD: ipsecadm.c,v 1.42 2000/09/21 01:34:19 angelos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -864,7 +864,13 @@ main(int argc, char **argv)
exit(1);
}
- srcid = argv[i + 1];
+ srcid = calloc(ROUNDUP(strlen(argv[i + 1])), sizeof(char));
+ if (srcid == NULL)
+ {
+ fprintf(stderr, "%s: malloc failed\n", argv[0]);
+ exit(1);
+ }
+ strcpy(srcid, argv[i + 1]);
sid1.sadb_ident_len += ROUNDUP(strlen(srcid)) / sizeof(u_int64_t);
i++;
continue;
@@ -880,7 +886,13 @@ main(int argc, char **argv)
exit(1);
}
- dstid = argv[i + 1];
+ dstid = calloc(ROUNDUP(strlen(argv[i + 1])), sizeof(char));
+ if (dstid == NULL)
+ {
+ fprintf(stderr, "%s: malloc failed\n", argv[0]);
+ exit(1);
+ }
+ strcpy(dstid, argv[i + 1]);
sid2.sadb_ident_len += ROUNDUP(strlen(dstid)) / sizeof(u_int64_t);
i++;
continue;