summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2005-11-22 16:00:50 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2005-11-22 16:00:50 +0000
commitaa3d8295b8088243fc4fa1bd33bfba5621e57069 (patch)
treeb07e141aabadd51a9f98c14c6e6ce47ca4b940a2 /usr.bin
parentfb64a851e456aa75ea7af2e17b3b70b0f1c111f8 (diff)
out-of-bounds access; ok otto@, millert@, deraadt@
Diffstat (limited to 'usr.bin')
-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);
}