From c4bb310e49d5d77b2b1b8ac4519a96ec71f6f3b5 Mon Sep 17 00:00:00 2001 From: Martynas Venckus Date: Thu, 2 Jul 2009 16:29:16 +0000 Subject: avoid infinite recursion if unlink fails. reported by Stefan Pettersson ok theo, millert@ --- bin/ksh/history.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bin') 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; -- cgit v1.2.3