Re: texinfo 4.6.93 pretest available

Jim Meyering <[email protected]> Sat, 27 Mar 2004 13:06:18 +0100
Newsgroups gmane.comp.tex.texinfo.pretest
Message-ID <[email protected]>
> Please test if time and inclination, and of course report any problems,
> preferably to [email protected].  The NEWS follows.

Hi Karl,

May I suggest that you add a test that runs info on texinfo's own info files?

When I run the latest like this, it exposes a problem:

  $ valgrind -q ./ginfo emacs > out 2>err
  $ grep -v Writing.node err > k

Some of the valgrind results are appended below.
As they suggest, something is going wrong at info-utils.c:112

    96    i = skip_node_characters (string, newlines_okay);
    97    saven_nodename (string, i);
    98    canonicalize_whitespace (info_parsed_nodename);
    99    if (info_parsed_nodename && !*info_parsed_nodename)
   100      {
   101        free (info_parsed_nodename);
   102        info_parsed_nodename = (char *)NULL;
   103      }
   104
   105    /* Parse ``(line ...)'' part of menus, if any.  */
   106    {
   107      char *rest = (char *) (string + i + 1);
   108
   109      /* Skip any whitespace first, and then a newline in case the item
   110         was so long to contain the ``(line ...)'' string in the same
   111         physical line.  */
   112      while (whitespace(*rest))
   113        rest++;
   114      if (*rest == '\n')
   115        {
   116          rest++;
   117          while (whitespace(*rest))
   118            rest++;
   119        }

With the following patch, it passes the above test.

2004-03-27  Jim Meyering  <[email protected]>

	* info/info-utils.c (info_parse_node): Don't read beyond end
        of buffer when looking for ``(line ...)'' in a menu item.

--- info-utils.c.~1~	2004-03-27 12:24:16.000000000 +0100
+++ info-utils.c	2004-03-27 12:48:09.000000000 +0100
@@ -104,7 +104,11 @@ info_parse_node (char *string, int newli
 
   /* Parse ``(line ...)'' part of menus, if any.  */
   {
-    char *rest = (char *) (string + i + 1);
+    char *rest = string + i;
+
+    /* Advance only if it's not already at end of string.  */
+    if (*rest)
+      rest++;
 
     /* Skip any whitespace first, and then a newline in case the item
        was so long to contain the ``(line ...)'' string in the same


==22690== Invalid read of size 1
==22690==    at 0x804FEF2: info_parse_node (info-utils.c:112)
==22690==    by 0x80562DD: info_get_node (nodes.c:88)
==22690==    by 0x805D6DB: dump_node_to_stream (session.c:3190)
==22690==    by 0x805D9C3: dump_node_to_file (session.c:3280)
==22690==  Address 0x4188FD00 is 0 bytes after a block of size 4 alloc'd
==22690==    at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==22690==    by 0x80648D7: xmalloc (xmalloc.c:38)
==22690==    by 0x8056F17: get_nodes_of_tags_table (nodes.c:661)
==22690==    by 0x805703D: get_tags_of_indirect_tags_table (nodes.c:704)
==22690==
...
_______________________________________________
Texinfo home page: http://www.gnu.org/software/texinfo/
[email protected]
http://ff0.org/mailman/listinfo/texinfo-pretest