Re: [Chicken-hackers] [PATCH] Fix unsafe specializations in types.db

2015-09-06 Thread John Cowan
Moritz Heidkamp scripsit:

> The only one I'm a bit unhappy about is `move-memory!' as I couldn't
> find a safe inline version of it. Does anyone have a clue whether there
> is such a thing already?

Presumably that would check lengths only while leaving types to be validated
by the scrutinizer?

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
"Any legal document draws most of its meaning from context.  A telegram
that says 'SELL HUNDRED THOUSAND SHARES IBM SHORT' (only 190 bits in
5-bit Baudot code plus appropriate headers) is as good a legal document
as any, even sans digital signature." --me

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Ensure try-compile cleans up tempfiles (#1213)

2015-09-06 Thread Moritz Heidkamp
Hi Peter,

On 24 August 2015 21:52 CEST, Peter Bex wrote:

> I noticed that try-compile leaves a temp.1234.o file in the current
> directory when invoked (see #1213).   The definition actually has a
> "oname" variable, but it isn't used.  So the attached patch causes it
> to explicitly pass "-o ONAME" to the compiler, to ensure that it
> writes to that file (which should now be created under the tempdir
> instead of the current directory as an added bonus), and then removes
> it.

thanks for the patch, I applied it to the latest master and everything
seems to work fine. I also manually tested it with a dummy egg which
uses try-compile.


> Perhaps we should also try adding shellpath to *target-lib-home*, but
> I decided to keep this change self-contained and ask, first.

I think this is a trivial and uncontroversial change, feel free to just
apply it!


> This change should also go into the chicken-5 branch, I think.

I did that, too, using the same test as above.

Moritz


signature.asc
Description: PGP signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Fix unsafe specializations in types.db

2015-09-06 Thread Moritz Heidkamp
Hi everyone,

the attached patch addresses the issue explained in
https://bugs.call-cc.org/ticket/1216 as well as similar ones I found by
sifting through the whole of types.db, though I can't guarantee that any
other instances slipped my attention, of course.

The only one I'm a bit unhappy about is `move-memory!' as I couldn't
find a safe inline version of it. Does anyone have a clue whether there
is such a thing already?

Moritz
From c40e4f11abb29c6f2451656a3c09ea3272c5ddb8 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp 
Date: Sat, 5 Sep 2015 00:24:32 +0200
Subject: [PATCH] Fix unsafe specializations in types.db

This patch fixes some specializations in types.db which could lead to
unsafe code. In all cases, the specialized versions did not only elide
runtime type checks but also range checks for their arguments. For
example, `string-ref' could have been specialized so that it would allow
for an index pointing past the end of the string to be passed.

Fixes #1216.
---
 types.db | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/types.db b/types.db
index b79020c..4058872 100644
--- a/types.db
+++ b/types.db
@@ -551,10 +551,10 @@
 	   ((string) (##sys#size #(1
 
 (string-ref (#(procedure #:clean #:enforce) string-ref (string fixnum) char)
-	((string fixnum) (##core#inline "C_subchar" #(1) #(2
+	((string fixnum) (##core#inline "C_i_string_ref" #(1) #(2
 
 (string-set! (#(procedure #:enforce) string-set! (string fixnum char) undefined)
-	 ((string fixnum char) (##core#inline "C_setsubchar" #(1) #(2) #(3
+	 ((string fixnum char) (##core#inline "C_i_string_set" #(1) #(2) #(3
 
 (string-append (#(procedure #:clean #:enforce) string-append (#!rest string) string)
 	   ((string string) (##sys#string-append #(1) #(2
@@ -731,7 +731,7 @@
 (arithmetic-shift (#(procedure #:clean #:enforce) arithmetic-shift (number number) number))
 
 (bit-set? (#(procedure #:clean #:enforce) bit-set? (number fixnum) boolean)
-	  ((fixnum fixnum) (##core#inline "C_u_i_bit_setp" #(1) #(2
+	  ((fixnum fixnum) (##core#inline "C_i_bit_setp" #(1) #(2
 
 (bitwise-and (#(procedure #:clean #:enforce) bitwise-and (#!rest number) number)
 	 ((fixnum fixnum) (fixnum)
@@ -1488,19 +1488,7 @@
 (make-record-instance (#(procedure #:clean) make-record-instance (symbol #!rest) *))
 (make-weak-locative (#(procedure #:clean #:enforce) make-weak-locative (* #!optional fixnum) locative))
 
-(move-memory! (#(procedure #:enforce) move-memory! (* * #!optional fixnum fixnum fixnum) *)
-	  ((pointer pointer fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 '0))
-	  ((pointer pointer fixnum fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 #(4)))
-	  ((pointer pointer fixnum fixnum fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) #(5) #(4)))
-	  ((locative locative fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 '0))
-	  ((locative locative fixnum fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) '0 #(4)))
-	  ((locative locative fixnum fixnum fixnum)
-	   (##core#inline "C_copy_ptr_memory" #(2) #(1) #(3) #(5) #(4
+(move-memory! (#(procedure #:enforce) move-memory! (* * #!optional fixnum fixnum fixnum) *))
 
 (mutate-procedure!
  (#(procedure #:enforce) mutate-procedure! (procedure (procedure (procedure) . *)) procedure))
-- 
2.4.6



signature.asc
Description: PGP signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers