Hi Peter,

On 2017-11-02 10:59, Peter Bex wrote:
This doesn't take care of the situation where the input port is closed,
in which case an error should be thrown.

Oh yeah, I totally forgot about that. Let's just drop the rewrite for
now. Patch attached.

Thanks,

Evan
>From 4a34854cb2e3c93a6d07cbe15e83c23c7a7b4c5d Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Mon, 6 Nov 2017 17:43:29 +1300
Subject: [PATCH] Drop `read-string' rewrite from c-platform.scm

After 25064a3c, the c-platform rewrite for `read-string' would ignore
its second argument and use an internal version of the procedure
whenever at least one argument was given, leading to potentially unsafe
behaviour since the type of that second argument wouldn't be checked (it
must be an *open* input port).

To fix this, we simply remove the rewrite so the port argument is always
checked at runtime.
---
 c-platform.scm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/c-platform.scm b/c-platform.scm
index d2323fe8..523ad20f 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -1053,7 +1053,6 @@
 
 (rewrite 'scheme#read-char 23 0 '##sys#read-char/port '##sys#standard-input)
 (rewrite 'scheme#write-char 23 1 '##sys#write-char/port '##sys#standard-output)
-(rewrite 'chicken.io#read-string 23 1 'chicken.io#read-string/port '##sys#standard-input)
 (rewrite 'chicken.string#substring=? 23 2 '##sys#substring=? 0 0 #f)
 (rewrite 'chicken.string#substring-ci=? 23 2 '##sys#substring-ci=? 0 0 #f)
 (rewrite 'chicken.string#substring-index 23 2 '##sys#substring-index 0)
-- 
2.11.0

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to