summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff3/diff3prog.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2005-11-22 16:00:49 +0000
committermarkus <markus@openbsd.org>2005-11-22 16:00:49 +0000
commit6daeeae149c6db8d691c396b238620bd72426898 (patch)
treeb01404a5ca50744177ca176424e06d2f7436f5f7 /usr.bin/diff3/diff3prog.c
parententer diff3 (diff)
downloadwireguard-openbsd-6daeeae149c6db8d691c396b238620bd72426898.tar.xz
wireguard-openbsd-6daeeae149c6db8d691c396b238620bd72426898.zip
out-of-bounds access; ok otto@, millert@, deraadt@
Diffstat (limited to 'usr.bin/diff3/diff3prog.c')
-rw-r--r--usr.bin/diff3/diff3prog.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/diff3/diff3prog.c b/usr.bin/diff3/diff3prog.c
index 7e109b04de6..5b7f6d83ee5 100644
--- a/usr.bin/diff3/diff3prog.c
+++ b/usr.bin/diff3/diff3prog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3prog.c,v 1.7 2005/08/01 08:17:57 otto Exp $ */
+/* $OpenBSD: diff3prog.c,v 1.8 2005/11/22 16:00:49 markus Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -71,7 +71,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.7 2005/08/01 08:17:57 otto Exp $";
+static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.8 2005/11/22 16:00:49 markus Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -240,8 +240,10 @@ readin(char *name, struct diff **dd)
(*dd)[i].new.from = c;
(*dd)[i].new.to = d;
}
- (*dd)[i].old.from = (*dd)[i-1].old.to;
- (*dd)[i].new.from = (*dd)[i-1].new.to;
+ if (i) {
+ (*dd)[i].old.from = (*dd)[i-1].old.to;
+ (*dd)[i].new.from = (*dd)[i-1].new.to;
+ }
(void)fclose(fp[0]);
return (i);
}