summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mopd
diff options
context:
space:
mode:
authormaja <maja@openbsd.org>2009-11-12 16:52:22 +0000
committermaja <maja@openbsd.org>2009-11-12 16:52:22 +0000
commit86d3f013a93de46d3931917fa4d5bb4d238a27f1 (patch)
tree1f67a3c726baf1a0c49ff35d5efe81b27a7dcaa1 /usr.sbin/mopd
parentfix memory leak found by parfait; ok jsg@ (diff)
downloadwireguard-openbsd-86d3f013a93de46d3931917fa4d5bb4d238a27f1.tar.xz
wireguard-openbsd-86d3f013a93de46d3931917fa4d5bb4d238a27f1.zip
Make life easier for parfait. I corporation with deraadt. -moj
Diffstat (limited to 'usr.sbin/mopd')
-rw-r--r--usr.sbin/mopd/mopd/process.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.sbin/mopd/mopd/process.c b/usr.sbin/mopd/mopd/process.c
index 524fdd49705..2cfc60a3946 100644
--- a/usr.sbin/mopd/mopd/process.c
+++ b/usr.sbin/mopd/mopd/process.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process.c,v 1.18 2009/10/27 23:59:52 deraadt Exp $ */
+/* $OpenBSD: process.c,v 1.19 2009/11/12 16:52:22 maja Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -164,19 +164,17 @@ mopStartLoad(u_char *dst, u_char *src, struct dllist *dl_rpr, int trans)
slot = -1;
/* Look if we have a non terminated load, if so, use it's slot */
- for (i = 0; i < MAXDL; i++)
+ for (i = 0; i < MAXDL && slot == -1; i++)
if (dllist[i].status != DL_STATUS_FREE)
if (mopCmpEAddr(dllist[i].eaddr, dst) == 0)
slot = i;
/* If no slot yet, then find first free */
- if (slot == -1)
- for (i = 0; i < MAXDL; i++)
- if (dllist[i].status == DL_STATUS_FREE)
- if (slot == -1) {
- slot = i;
- bcopy(dst, dllist[i].eaddr, 6);
- }
+ for (i = 0; slot == -1 && i < MAXDL; i++)
+ if (dllist[i].status == DL_STATUS_FREE) {
+ slot = i;
+ bcopy(dst, dllist[i].eaddr, 6);
+ }
/* If no slot yet, then return. No slot is free */
if (slot == -1)
@@ -248,7 +246,7 @@ mopNextLoad(u_char *dst, u_char *src, u_char new_count, int trans)
slot = -1;
- for (i = 0; i < MAXDL; i++)
+ for (i = 0; i < MAXDL && slot == -1; i++)
if (dllist[i].status != DL_STATUS_FREE) {
if (mopCmpEAddr(dst, dllist[i].eaddr) == 0)
slot = i;