summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mopd
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-11-30 13:47:42 +0000
committermiod <miod@openbsd.org>2014-11-30 13:47:42 +0000
commit9345b20007647d596f6a485c3b3d0aec8b8b748d (patch)
tree2ec0afaaf0b67caf8108c0c2b5a44c1b35e8382c /usr.sbin/mopd
parentclear progress meter before asking questions (diff)
downloadwireguard-openbsd-9345b20007647d596f6a485c3b3d0aec8b8b748d.tar.xz
wireguard-openbsd-9345b20007647d596f6a485c3b3d0aec8b8b748d.zip
In mopFileRead(), make sure to never increment e_cursec beyond e_nsec, so
that the next call to this function will not access e_sections[] out of bounds. Repairs mopa.out(1) behaviour noticed by sebastia@
Diffstat (limited to 'usr.sbin/mopd')
-rw-r--r--usr.sbin/mopd/common/file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/mopd/common/file.c b/usr.sbin/mopd/common/file.c
index 1432ceead5c..5382d35ab1c 100644
--- a/usr.sbin/mopd/common/file.c
+++ b/usr.sbin/mopd/common/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.15 2013/10/17 08:02:21 deraadt Exp $ */
+/* $OpenBSD: file.c,v 1.16 2014/11/30 13:47:42 miod Exp $ */
/*
* Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
@@ -975,7 +975,8 @@ mopFileRead(struct dllist *dlslot, u_char *buf)
if (dlslot->e_curpos >= (dlslot->e_sections[sec].s_loff +
dlslot->e_sections[sec].s_fsize +
dlslot->e_sections[sec].s_pad))
- dlslot->e_cursec++;
+ if (++sec != dlslot->e_nsec)
+ dlslot->e_cursec = sec;
break;
case IMAGE_TYPE_AOUT: