Re: texinfo 4.6.91 pretest available
Jim Meyering <[email protected]> Sun, 14 Mar 2004 21:35:08 +0100
| Newsgroups | gmane.comp.tex.texinfo.pretest |
|---|---|
| Message-ID | <[email protected]> |
Hi Karl!
I ran all of the makeinfo tests through valgrind.
(I instrumented the test scripts like this:
cd makeinfo/tests/
perl -pi -e 's,\.\./makeinfo,valgrind ../makeinfo,' *
)
With that change, running `make check' exposed a few problems.
I've included patches for four of them, below.
In case it matters, this is on a linux-2.6.4 system with valgrind-2.1.0.
Here are the errors I haven't looked at:
==19799== Source and destination overlap in strncpy(0x4158C425, 0x4158C426, 3)
==19799== at 0x400240B0: strncpy (mac_replace_strmem.c:93)
==19799== by 0x805C218: add_char (makeinfo.c:2691)
==19799== by 0x805B8C6: reader_loop (makeinfo.c:2237)
==19799== by 0x805A8E2: convert_from_loaded_file (makeinfo.c:1652)
------------------------------------------
==19715== Invalid write of size 1
==19715== at 0x40023D87: strcat (mac_replace_strmem.c:125)
==19715== by 0x804E47E: add_new_float (float.c:50)
==19715== by 0x80536EA: begin_insertion (insertion.c:814)
==19715== by 0x8054D20: cm_float (insertion.c:1875)
==19715== Address 0x41DB1167 is 0 bytes after a block of size 3 alloc'd
==19715== at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==19715== by 0x80690AF: xmalloc (xmalloc.c:42)
==19715== by 0x806912D: xstrdup (xstrdup.c:32)
==19715== by 0x8062E35: current_chapter_number (sectioning.c:267)
==19715==
==19715== Invalid read of size 1
==19715== at 0x40023F0E: strlen (mac_replace_strmem.c:162)
==19715== by 0x804E568: count_floats_of_type_in_chapter (float.c:80)
==19715== by 0x804E49D: add_new_float (float.c:55)
==19715== by 0x80536EA: begin_insertion (insertion.c:814)
==19715== Address 0x41DB1167 is 0 bytes after a block of size 3 alloc'd
==19715== at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==19715== by 0x80690AF: xmalloc (xmalloc.c:42)
==19715== by 0x806912D: xstrdup (xstrdup.c:32)
==19715== by 0x8062E35: current_chapter_number (sectioning.c:267)
==19715==
==19715== Invalid read of size 1
==19715== at 0x40023F0E: strlen (mac_replace_strmem.c:162)
==19715== by 0x40297134: _IO_vfprintf (in /lib/libc-2.3.2.so)
==19715== by 0x402B518F: __vsnprintf (in /lib/libc-2.3.2.so)
==19715== by 0x4029D6F3: snprintf (in /lib/libc-2.3.2.so)
==19715== Address 0x41DB1167 is 0 bytes after a block of size 3 alloc'd
==19715== at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==19715== by 0x80690AF: xmalloc (xmalloc.c:42)
==19715== by 0x806912D: xstrdup (xstrdup.c:32)
==19715== by 0x8062E35: current_chapter_number (sectioning.c:267)
2004-03-14 Jim Meyering <[email protected]>
* makeinfo/index.c (insert_index_output_line_no): Ensure that `i'
is larger than zero before (not after) using `i-1' as an array index.
* makeinfo/cmds.c (cm_acronym): Don't write description[-1]
when description is the empty string.
* makeinfo/makeinfo.c (insert): Avoid buffer under-run when
output_paragraph_offset is zero.
(canon_white): Rewrite not to use strcpy (was used with
overlapping source and destination)
Index: makeinfo/index.c
===================================================================
--- makeinfo/index.c (revision 1)
+++ makeinfo/index.c (working copy)
@@ -664,7 +664,7 @@
{
int i = output_paragraph_offset;
- while (output_paragraph[i-1] != '\n' && i > 0)
+ while (0 < i && output_paragraph[i-1] != '\n')
i--;
last_column = output_paragraph_offset - i;
}
Index: makeinfo/cmds.c
===================================================================
--- makeinfo/cmds.c (revision 1)
+++ makeinfo/cmds.c (working copy)
@@ -653,6 +653,7 @@
cm_acronym (int arg)
{
char *acronym, *description;
+ size_t len;
/* We do everything at START. */
if (arg == END)
@@ -680,9 +681,11 @@
/* Get description out of braces. */
if (description[0] == '{')
description++;
- if (description[strlen (description)-1] == '}')
- description[strlen (description)-1] = '\0';
+ len = strlen (description);
+ if (len && description[len-1] == '}')
+ description[len-1] = '\0';
+
/* Save new description. */
if (strlen (description) > 0)
{
Index: makeinfo/makeinfo.c
===================================================================
--- makeinfo/makeinfo.c (revision 1)
+++ makeinfo/makeinfo.c (working copy)
@@ -888,26 +888,28 @@
void
canon_white (char *string)
{
- int len = strlen (string);
- int x;
+ char *p = string;
+ size_t len;
- if (!len)
+ if (!*p)
return;
- for (x = 0; x < len; x++)
+ do
{
- if (!cr_or_whitespace (string[x]))
- {
- strcpy (string, string + x);
- break;
- }
+ if (!cr_or_whitespace (*p))
+ break;
+ ++p;
}
- len = strlen (string);
- if (len)
- len--;
- while (len > -1 && cr_or_whitespace (string[len]))
- len--;
- string[len + 1] = 0;
+ while (*p);
+
+ len = strlen (p);
+ while (len && cr_or_whitespace (p[len-1]))
+ --len;
+
+ if (p != string)
+ memmove (string, p, len);
+
+ string[len] = 0;
}
/* Bash STRING, replacing all whitespace with just one space. */
@@ -2765,8 +2767,11 @@
because it looks like a @subsection. Adding a trailing space to those
lines fixes it. */
if (character == '\n' && !html && !xml && !multitable_active)
- while (whitespace (output_paragraph[output_paragraph_offset-1]))
- output_paragraph_offset--;
+ {
+ while (output_paragraph_offset
+ && whitespace (output_paragraph[output_paragraph_offset-1]))
+ output_paragraph_offset--;
+ }
output_paragraph[output_paragraph_offset++] = character;
if (output_paragraph_offset == paragraph_buffer_len)
_______________________________________________
Texinfo home page: http://www.gnu.org/software/texinfo/
[email protected]
http://ff0.org/mailman/listinfo/texinfo-pretest