unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Julian Graham" <joolean@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: segfault in SRFI-1 partition on non-list input
Date: Mon, 28 Apr 2008 00:37:11 -0400	[thread overview]
Message-ID: <2bc5f8210804272137he4b80e0v314cefc34eb327d1@mail.gmail.com> (raw)

[-- 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


             reply	other threads:[~2008-04-28  4:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-28  4:37 Julian Graham [this message]
2008-04-28  8:27 ` segfault in SRFI-1 partition on non-list input 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bc5f8210804272137he4b80e0v314cefc34eb327d1@mail.gmail.com \
    --to=joolean@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).