summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2009-07-02 16:29:16 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2009-07-02 16:29:16 +0000
commitc4bb310e49d5d77b2b1b8ac4519a96ec71f6f3b5 (patch)
tree1f378fc3965c41b0448510cc19ecc0ab9060ac5b /bin
parente28d27751ccaf23406c552206f2097e666c75aae (diff)
avoid infinite recursion if unlink fails. reported by Stefan Pettersson
ok theo, millert@
Diffstat (limited to 'bin')
-rw-r--r--bin/ksh/history.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/ksh/history.c b/bin/ksh/history.c
index 68475bef654..72ce075b499 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.36 2008/05/20 00:30:30 fgsch Exp $ */
+/* $OpenBSD: history.c,v 1.37 2009/07/02 16:29:15 martynas Exp $ */
/*
* command history
@@ -674,7 +674,8 @@ hist_init(Source *s)
if (base != MAP_FAILED)
munmap((caddr_t)base, hsize);
hist_finish();
- unlink(hname);
+ if (unlink(hname) != 0)
+ return;
goto retry;
}
if (hsize > 2) {
@@ -682,7 +683,8 @@ hist_init(Source *s)
if (lines > histsize) {
/* we need to make the file smaller */
if (hist_shrink(base, hsize))
- unlink(hname);
+ if (unlink(hname) != 0)
+ return;
munmap((caddr_t)base, hsize);
hist_finish();
goto retry;