summaryrefslogtreecommitdiffstats
path: root/system/pdksh/patches/116_OpenBSD-history.patch
blob: 9be184b29871adb5b97c0a3bbd15302cb13a161c (plain)
From OpenBSD:

2008-07-03 19:52  otto

        * lex.c (1.44): fix inifinite loop with set -o csh-history and
          !<space> as input.  report and testing by david@; ok millert@
          jaredy@

2008-05-20 02:30  fgsch

        * history.c (1.36): cast pointer arithmetic to unsigned so we can
          behave correctly on underflows. fixes fc -l 1 in my box where
          line is 1667511151.  krw@ ok.

Index: pdksh-5.2.14/history.c
===================================================================
--- pdksh-5.2.14.orig/history.c	2009-09-17 22:18:37.000000000 +0200
+++ pdksh-5.2.14/history.c	2009-09-17 23:46:06.000000000 +0200
@@ -385,7 +385,7 @@
 
 	if (getn(str, &n)) {
 		hp = histptr + (n < 0 ? n : (n - hist_source->line));
-		if (hp < history) {
+		if ((long)hp < (long)history) {
 			if (approx)
 				hp = hist_get_oldest();
 			else {
@@ -862,7 +862,8 @@
 			if (base !=  MAP_FAILED)
 				munmap((caddr_t)base, hsize);
 			hist_finish();
-			unlink(hname);
+			if (unlink(hname) != 0)
+				return;
 			goto retry;
 		}
 		if (hsize > 2) {
@@ -870,7 +871,8 @@
 			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;