From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thomas Danckaert Newsgroups: gmane.lisp.guile.bugs Subject: bug#26013: (srfi srfi-37) chokes on empty string parameter Date: Wed, 19 Apr 2017 18:32:29 +0200 (CEST) Message-ID: <20170419.183229.1069589305335594566.post@thomasdanckaert.be> References: <20170307.163454.2259447634066961490.post@thomasdanckaert.be> <87inm0l9be.fsf@igalia.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Apr_19_18_32_29_2017_093)--" Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1492619598 24932 195.159.176.226 (19 Apr 2017 16:33:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Apr 2017 16:33:18 +0000 (UTC) Cc: ludo@gnu.org, 26013@debbugs.gnu.org To: wingo@igalia.com Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Apr 19 18:33:12 2017 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0sXW-0006Jb-O0 for guile-bugs@m.gmane.org; Wed, 19 Apr 2017 18:33:10 +0200 Original-Received: from localhost ([::1]:49342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0sXc-0002HC-G9 for guile-bugs@m.gmane.org; Wed, 19 Apr 2017 12:33:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0sXP-0002H5-Bz for bug-guile@gnu.org; Wed, 19 Apr 2017 12:33:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0sXO-00028n-D8 for bug-guile@gnu.org; Wed, 19 Apr 2017 12:33:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59006) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0sXO-00028a-9O for bug-guile@gnu.org; Wed, 19 Apr 2017 12:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d0sXO-0004w8-10 for bug-guile@gnu.org; Wed, 19 Apr 2017 12:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thomas Danckaert Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 19 Apr 2017 16:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26013 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 26013-submit@debbugs.gnu.org id=B26013.149261956918958 (code B ref 26013); Wed, 19 Apr 2017 16:33:01 +0000 Original-Received: (at 26013) by debbugs.gnu.org; 19 Apr 2017 16:32:49 +0000 Original-Received: from localhost ([127.0.0.1]:57205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0sXB-0004vi-JG for submit@debbugs.gnu.org; Wed, 19 Apr 2017 12:32:49 -0400 Original-Received: from s02.spamexperts.axc.nl ([185.182.56.112]:32986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0sXA-0004vT-85 for 26013@debbugs.gnu.org; Wed, 19 Apr 2017 12:32:48 -0400 Original-Received: from vserver42.axc.nl ([185.182.56.92]) by s02.spamexperts.axc.nl with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86) (envelope-from ) id 1d0sX1-0001pl-OU; Wed, 19 Apr 2017 18:32:40 +0200 Original-Received: from mail.axc.nl ([185.182.56.42]:36396 helo=mail.axc.eu) by vserver42.axc.nl with esmtp (Exim 4.89) (envelope-from ) id 1d0sWx-00040y-Pg; Wed, 19 Apr 2017 18:32:37 +0200 In-Reply-To: <87inm0l9be.fsf@igalia.com> X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) PrimaryMX: Accepted email from trusted host. Hint: This skips spam scanning so make sure other host is not vulnerable X-Relay-Host: 185.182.56.42 SpamTally: Final spam score: 0 X-Originating-IP: 185.182.56.92 X-SpamExperts-Domain: vserver42.axc.nl X-SpamExperts-Username: 185.182.56.92 Authentication-Results: spamexperts.axc.nl; auth=pass smtp.auth=185.182.56.92@vserver42.axc.nl X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.05) X-Recommended-Action: accept X-Filter-ID: s0sct1PQhAABKnZB5plbIaExX4b9HB97Y0LqBeziPXa8B5kabb+8+DRlCqSxA333/bPom7IVowNb jNmNSGjlJADpxEq2QWue0NVTi1XPmXej1KRrf1Y8eevl1lZRQAkHO76XSTAwtV4mg4i2ouCDa4AU hvIWAV5xUW/+gAh4vXolO0yEJhSZr7NTh2PPHFU5RcOb18WfxGyg6Om6u4YYm2gKQW7jUi3hSDpe tlwbTsUvPRYKza70yK2TxRJHcdD+oEAP/to+02F3J4r01qcN199fxN2oReTDHAyOynaY0Cldue3r +qEeQYBWND7fDPGoUqYOv6lKxxeboK+YPP3g5J9Wyy39ARVu6lpph/EphEmSUaqSECP9/MJNMfS9 WPFvtKiR9oEdyOK7GnLP3Jw7nAFKpw6uarMIchUUKBPMSwqDyKMRQpLIgOCu6l+WvUOcQWML+Gfm 48knF3HyGP2khIbxR0PuC4wwYQTc8Sg/23VtqGjgyi5JHolhrWpNa9YQsl4SUWp4U8fCCSBjefGq te4ROxlmGgdR7QBaGWEQFYs+dvusjRV96oP1cmFb05OHyZAZLfpWinSu+danhtKvH9pAsaSpuQPS cbIWdeXhkZC4rAXOgWX2FBHgH187+EKv5hICVo92zvI9isesxBu4AK5YVcPPq3MXlUe9sP5+k0dp Y7f6EqR6zsgzOR3cDnOA00EAPbS4bNU8BUEaZ6GjPkeit7rjyZ8A02yt7AyZnjM6qQzLuCe/hQ3A 5i3Uw+OAbBH+DkNPnrywBHhKB8rPDBfx1bbfhyaO3VHMr4+RLj/ejVZe2CIQ4NKRrAu+ot9y06Je XLHNSvzSa4NcSCqr9miaum+Z7LbrU X-Report-Abuse-To: spam@s01.spamexperts.axc.nl X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8764 Archived-At: ----Next_Part(Wed_Apr_19_18_32_29_2017_093)-- Content-Type: Text/Plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit From: Andy Wingo Subject: Re: bug#26013: (srfi srfi-37) chokes on empty string parameter Date: Wed, 19 Apr 2017 17:13:25 +0200 > On Tue 07 Mar 2017 16:34, Thomas Danckaert > writes: > >> It looks like Guile's srfi-37 implementation doesn't process empty >> string arguments correctly. >> [...] >> In srfi/srfi-37.scm: >> 220: 1 [next-arg] >> In unknown file: >> ?: 0 [string-ref "" 0] >> >> ERROR: In procedure string-ref: >> ERROR: Value out of range: 0 > > Sounds like the right diagnosis to me. Want to submit a patch? :) Well, let me try :) I don't fully understand the code in srfi-37.scm, but I think the fix can be as simple as the attached patch (i.e. first check if the argument is empty, otherwise check if it starts with \#-). I have tried to follow the existing indentation convention, as far as I understand it (a mix of tabs and spaces). Thomas ----Next_Part(Wed_Apr_19_18_32_29_2017_093)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-SRFI-37-Account-for-zero-length-arguments.patch" >From bd0bd95e3786211effe728bae61ef5b02f6cc5f6 Mon Sep 17 00:00:00 2001 From: Thomas Danckaert Date: Wed, 19 Apr 2017 18:14:38 +0200 Subject: [PATCH] SRFI-37: Account for zero-length arguments. * module/srfi/srfi-37.scm (args-fold): When checking if an argument is an option (starts with #\-), first check if the length is non-zero. --- module/srfi/srfi-37.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/srfi/srfi-37.scm b/module/srfi/srfi-37.scm index 3f654af2c..c34b0d083 100644 --- a/module/srfi/srfi-37.scm +++ b/module/srfi/srfi-37.scm @@ -217,7 +217,8 @@ program-arguments in ARGS, as decided by the OPTIONS' (if (null? args) (apply values seeds) (let ((arg (car args))) - (cond ((or (not (char=? #\- (string-ref arg 0))) + (cond ((or (string-null? arg) + (not (char=? #\- (string-ref arg 0))) (= 1 (string-length arg))) ;"-" (mutate-seeds! operand-proc arg) (set! args (cdr args))) -- 2.12.2 ----Next_Part(Wed_Apr_19_18_32_29_2017_093)----