aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@noconroy.net>2020-05-18 22:02:53 +1000
committerMatt Dunwoodie <ncon@noconroy.net>2020-05-18 22:02:53 +1000
commit34048fff37bd7db68fbfeffba47e3b9bbd282eac (patch)
tree6819bdfefdfc407137d43777b5be9866a46cfe93
parentAlign handshake_touch to last_sent (diff)
downloadwireguard-openbsd-34048fff37bd7db68fbfeffba47e3b9bbd282eac.tar.xz
wireguard-openbsd-34048fff37bd7db68fbfeffba47e3b9bbd282eac.zip
Restore Jason's original growwgdata function, still keep == NULL
-rw-r--r--src/patches/ifconfig.patch21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/patches/ifconfig.patch b/src/patches/ifconfig.patch
index 8471705..10e3c7b 100644
--- a/src/patches/ifconfig.patch
+++ b/src/patches/ifconfig.patch
@@ -1,5 +1,5 @@
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
-index aefa23d157a..ffc5fae5eb6 100644
+index aefa23d157a..ee6d51aadb3 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -82,6 +82,7 @@
@@ -105,7 +105,7 @@ index aefa23d157a..ffc5fae5eb6 100644
#endif
trunk_status();
getifgroups();
-@@ -5623,6 +5663,289 @@ setifpriority(const char *id, int param)
+@@ -5623,6 +5663,288 @@ setifpriority(const char *id, int param)
warn("SIOCSIFPRIORITY");
}
@@ -147,33 +147,32 @@ index aefa23d157a..ffc5fae5eb6 100644
+}
+
+void *
-+growwgdata(size_t inc)
++growwgdata(size_t by)
+{
+ ptrdiff_t peer_offset, aip_offset;
+ void *ret;
+
-+ ensurewginterface();
++ if (wg_interface == NULL)
++ wgdata.wgd_size = sizeof(*wg_interface);
+
-+ /* Calcualate offsets in case realloc moves our memory block. */
+ peer_offset = (void *)wg_peer - (void *)wg_interface;
+ aip_offset = (void *)wg_aip - (void *)wg_interface;
+
-+ /* Add, reallocate and check realloc result. */
-+ wgdata.wgd_size += inc;
++ wgdata.wgd_size += by;
+ wgdata.wgd_interface = realloc(wg_interface, wgdata.wgd_size);
+ if (wgdata.wgd_interface == NULL)
+ err(1, "calloc");
++ if (wg_interface == NULL)
++ bzero(wgdata.wgd_interface, sizeof(*wg_interface));
+ wg_interface = wgdata.wgd_interface;
+
-+ /* Adjust our pointers to ensure they point into the memory block. */
+ if (wg_peer != NULL)
+ wg_peer = (void *)wg_interface + peer_offset;
+ if (wg_aip != NULL)
+ wg_aip = (void *)wg_interface + aip_offset;
+
-+ /* Zero out any new memory */
-+ ret = (void *)wg_interface + wgdata.wgd_size - inc;
-+ bzero(ret, inc);
++ ret = (void *)wg_interface + wgdata.wgd_size - by;
++ bzero(ret, by);
+
+ return ret;
+}