unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* segfault in SRFI-1 partition on non-list input
@ 2008-04-28  4:37 Julian Graham
  2008-04-28  8:27 ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Julian Graham @ 2008-04-28  4:37 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Hi,

It looks like scm_srfi1_partition in srfi/srfi-1.c fails to verify
that it's being called on a real list, and so expressions like:

(partition symbol? '(a b . c))

cause Guile to segfault.  Attached is a patch against HEAD that adds validation.


Regards,
Julian

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-fix-segfault-in-scm_srfi1_partition-on-non-list-inpu.patch --]
[-- Type: text/x-diff; name=0003-fix-segfault-in-scm_srfi1_partition-on-non-list-inpu.patch, Size: 1182 bytes --]

From 587b22534a40e16adee5f06e70f4d2b633142054 Mon Sep 17 00:00:00 2001
From: Julian Graham <julian@smokebottle.(none)>
Date: Mon, 28 Apr 2008 00:32:47 -0400
Subject: [PATCH] fix segfault in scm_srfi1_partition on non-list input

---
 srfi/ChangeLog |    5 +++++
 srfi/srfi-1.c  |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/srfi/ChangeLog b/srfi/ChangeLog
index 65ea3e9..eeedc30 100644
--- a/srfi/ChangeLog
+++ b/srfi/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-28  Julian Graham  <joolean@gmail.com>
+
+	* srfi-1.c (scm_srfi1_partition): Validate input to avoid
+	segfault when passed something that is not a list.
+
 2008-04-27  Ludovic Courtès  <ludo@gnu.org>
 
 	* srfi-1.c: Include <config.h>.
diff --git a/srfi/srfi-1.c b/srfi/srfi-1.c
index 2989a25..5036acd 100644
--- a/srfi/srfi-1.c
+++ b/srfi/srfi-1.c
@@ -1673,7 +1673,8 @@ SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
   SCM dropped_tail = dropped;
   
   SCM_ASSERT(call, pred, 2, FUNC_NAME);
-  
+  SCM_VALIDATE_LIST (2, list);
+
   for (; !SCM_NULL_OR_NIL_P (list); list = SCM_CDR(list)) {
     SCM elt = SCM_CAR(list);
     SCM new_tail = scm_cons(SCM_CAR(list), SCM_EOL);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-04-30  7:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28  4:37 segfault in SRFI-1 partition on non-list input Julian Graham
2008-04-28  8:27 ` Ludovic Courtès
2008-04-28  8:31   ` Ludovic Courtès
2008-04-28 13:41   ` Julian Graham
2008-04-28 15:28     ` Ludovic Courtès
2008-04-30  3:40       ` Julian Graham
2008-04-30  7:28         ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).