[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-idutils] mkid: avoid infloop when processing .el files
From: |
Jim Meyering |
Subject: |
[bug-idutils] mkid: avoid infloop when processing .el files |
Date: |
Fri, 19 Jan 2007 15:57:14 +0100 |
With an input file named foo.el, containing an open bracket followed
by a non-close-bracket, mkid would infloop. Part of the problem is that
the code would try to ungetc two or three bytes with no intervening input.
As a temporary work-around, I've disabled the code that would treat '[]' as
part of a kawa identifier and added a test case.
If someone if motivated to re-enable handling of '[]' in kawa tokens,
please send a patch.
Here's the change I've just checked in:
Temporary fix simply to avoid the infloop.
* libidu/scanners.c (get_token_lisp): Disable the code that
treats '[]' as part of a kawa identifier. It could call ungetc
two or three times in a row. One is the maximum.
* testsuite/infloop-kawa-el: New file. Test for the above.
* testsuite/Makefile.am (TESTS): Add infloop-kawa-el.
(TESTS_ENVIRONMENT): Prepend build directory to PATH so that
invoking e.g., "mkid" runs the just-built version of the tool.
Index: libidu/scanners.c
===================================================================
RCS file: /sources/idutils/idutils/libidu/scanners.c,v
retrieving revision 1.20
diff -u -p -r1.20 scanners.c
--- libidu/scanners.c 25 Nov 2006 14:05:50 -0000 1.20
+++ libidu/scanners.c 19 Jan 2007 14:55:29 -0000
@@ -1,5 +1,5 @@
/* scanners.c -- file & directory name manipulations
- Copyright (C) 1986, 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1995, 1996, 1999, 2000, 2007 Free Software Foundation,
Inc.
Written by Greg McGary <address@hidden>
This program is free software; you can redistribute it and/or modify
@@ -1749,7 +1749,7 @@ get_token_lisp (FILE *in_FILE, void cons
{
while (is_IDENT (c = getc (in_FILE)))
*id++ = c;
- if (c == '[')
+ if (0 /* c == '[' */)
{
c = getc (in_FILE);
if (c == ']')
Index: testsuite/infloop-kawa-el
===================================================================
RCS file: testsuite/infloop-kawa-el
diff -N testsuite/infloop-kawa-el
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/infloop-kawa-el 19 Jan 2007 14:55:29 -0000
@@ -0,0 +1,58 @@
+#!/bin/sh
+# This would provoke an infloop with source from 4.2+ (cvs as of 2007-01-19).
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ mkid --version
+fi
+
+pwd=`pwd`
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit
$status' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+framework_failure=0
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+echo 'boo[! bar[]' > f.el || framework_failure=1
+
+# FIXME: The expected output should probably be these two lines:
+# bar
+# boo[]
+# but the code to handle that (now-disabled) did a double-ungetc.
+cat <<EOF > exp || framework_failure=1 # expect no output
+bar
+boo
+EOF
+
+if test $framework_failure = 1; then
+ echo "$0: failure in testing framework" 1>&2
+ (exit 1); exit 1
+fi
+
+fail=0
+
+mkid f.el > out || fail=1
+aid -R none b >> out || fail=1
+
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+(exit $fail); exit $fail
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/idutils/idutils/testsuite/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- testsuite/Makefile.am 15 Dec 2005 14:27:19 -0000 1.3
+++ testsuite/Makefile.am 19 Jan 2007 14:55:29 -0000
@@ -1,6 +1,11 @@
## Process this file with automake to create Makefile.in
-TESTS = consistency
+TESTS = \
+ consistency \
+ infloop-kawa-el
+
+TESTS_ENVIRONMENT = \
+ PATH="$(abs_builddir)/../src$(PATH_SEPARATOR)$$PATH"
EXTRA_DIST = $(TESTS) single_file_token_bug.c
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-idutils] mkid: avoid infloop when processing .el files,
Jim Meyering <=