diff --git a/chicken.spec b/chicken.spec index 1f296be..65d96d7 100644 --- a/chicken.spec +++ b/chicken.spec @@ -46,8 +46,6 @@ Scheme language standard, and includes many enhancements and extensions. %prep %setup -q -n %{name}-%{version} %patch0 -p1 -%patch1 -p1 -%patch2 -p1 %build %if %{bootstrap} == 0 diff --git a/rhbz-1181483.patch b/rhbz-1181483.patch deleted file mode 100644 index 28a081c..0000000 --- a/rhbz-1181483.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 230eed2745ea2b57de3c9073e8596892b1da2d8c Mon Sep 17 00:00:00 2001 -From: Moritz Heidkamp -Date: Sun, 14 Dec 2014 23:33:52 +0100 -Subject: [PATCH] Fix buffer overrun in substring-index[-ci] - -When passing a start index greater than 0, substring-index[-ci] would -scan past the end of the subject string, leading to bogus results in -case the substring is accidentally run into beyond the end of the -subject. This patch fixes the issue and also adds a range check for the -start index. ---- - data-structures.scm | 22 ++++++++++++++-------- - tests/data-structures-tests.scm | 11 ++++++++++- - 2 files changed, 24 insertions(+), 9 deletions(-) - -diff --git a/data-structures.scm b/data-structures.scm -index a94c163..511a3c1 100644 ---- a/data-structures.scm -+++ b/data-structures.scm -@@ -307,15 +307,21 @@ - (define (traverse which where start test loc) - (##sys#check-string which loc) - (##sys#check-string where loc) -- (let ([wherelen (##sys#size where)] -- [whichlen (##sys#size which)] ) -+ (let* ((wherelen (##sys#size where)) -+ (whichlen (##sys#size which)) -+ (end (fx- wherelen whichlen))) - (##sys#check-exact start loc) -- (let loop ([istart start] [iend whichlen]) -- (cond [(fx> iend wherelen) #f] -- [(test istart whichlen) istart] -- [else -- (loop (fx+ istart 1) -- (fx+ iend 1) ) ] ) ) ) ) -+ (if (and (fx>= start 0) -+ (fx> wherelen start)) -+ (let loop ((istart start)) -+ (cond ((fx> istart end) #f) -+ ((test istart whichlen) istart) -+ (else (loop (fx+ istart 1))))) -+ (##sys#error-hook (foreign-value "C_OUT_OF_RANGE_ERROR" int) -+ loc -+ start -+ wherelen)))) -+ - (set! ##sys#substring-index - (lambda (which where start) - (traverse -diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm -index 51c25a9..34ccb2f 100644 ---- a/tests/data-structures-tests.scm -+++ b/tests/data-structures-tests.scm -@@ -1,6 +1,6 @@ - ;;;; data-structures-tests.scm - --(use data-structures) -+(use data-structures lolevel) - - (define-syntax assert-error - (syntax-rules () -@@ -57,6 +57,15 @@ - (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00a"))) - (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00A"))) - -+ -+;; This used to fail because substring-index and co. used to search -+;; beyond the end of the subject string when a start index > 0 was -+;; provided. We use object-evict to ensure that the strings are placed -+;; in adjacent memory ranges so we can detect this error. -+(let* ((foo (object-evict (make-string 32 #\x))) -+ (bar (object-evict "y"))) -+ (assert (not (substring-index "y" foo 30)))) -+ - ;; topological-sort - - (assert (equal? '() (topological-sort '() eq?))) --- -2.1.3 - diff --git a/rhbz-1231871.patch b/rhbz-1231871.patch deleted file mode 100644 index 16b4f2e..0000000 --- a/rhbz-1231871.patch +++ /dev/null @@ -1,61 +0,0 @@ -diff --git a/data-structures.scm b/data-structures.scm -index b67065e..5664d08 100644 ---- a/data-structures.scm -+++ b/data-structures.scm -@@ -514,7 +514,7 @@ - (define (string-translate* str smap) - (##sys#check-string str 'string-translate*) - (##sys#check-list smap 'string-translate*) -- (let ([len (##sys#size str)]) -+ (let ((len (##sys#size str))) - (define (collect i from total fs) - (if (fx>= i len) - (##sys#fragments->string -@@ -523,15 +523,16 @@ - (if (fx> i from) - (cons (##sys#substring str from i) fs) - fs) ) ) -- (let loop ([smap smap]) -+ (let loop ((smap smap)) - (if (null? smap) - (collect (fx+ i 1) from (fx+ total 1) fs) -- (let* ([p (car smap)] -- [sm (car p)] -- [smlen (string-length sm)] -- [st (cdr p)] ) -- (if (##core#inline "C_substring_compare" str sm i 0 smlen) -- (let ([i2 (fx+ i smlen)]) -+ (let* ((p (car smap)) -+ (sm (car p)) -+ (smlen (string-length sm)) -+ (st (cdr p)) ) -+ (if (and (fx<= (fx+ i smlen) len) -+ (##core#inline "C_substring_compare" str sm i 0 smlen)) -+ (let ((i2 (fx+ i smlen))) - (when (fx> i from) - (set! fs (cons (##sys#substring str from i) fs)) ) - (collect -diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm -index 51c25a9..b576807 100644 ---- a/tests/data-structures-tests.scm -+++ b/tests/data-structures-tests.scm -@@ -57,6 +57,17 @@ - (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00a"))) - (assert (< 0 (string-compare3-ci "foo\x00b" "foo\x00A"))) - -+(assert (string=? "bde" (string-translate* "abcd" -+ '(("a" . "b") -+ ("b" . "") -+ ("c" . "d") -+ ("d" . "e"))))) -+(assert (string=? "bc" (string-translate* "abc" -+ '(("ab" . "b") -+ ("bc" . "WRONG"))))) -+(assert (string=? "x" (string-translate* "ab" '(("ab" . "x"))))) -+(assert (string=? "xy" (string-translate* "xyz" '(("z" . ""))))) -+ - ;; topological-sort - - (assert (equal? '() (topological-sort '() eq?))) --- -2.1.4