summaryrefslogtreecommitdiff
path: root/system/pdksh/patches/116_OpenBSD-history.patch
blob: 9be184b29871adb5b97c0a3bbd15302cb13a161c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;