Sat 17 Sep 2011 07:46:32 PM UTC, original submission:
After upgrading glibc, I found that chktex was unable to follow the names of \input commands, because it misdetected the name between the {} delimiter pair.
For instance, for the sample files main.tex:
\documentclass{article}
\input{part}
and part.tex:
\begin{document}
A \dots B
\end{document}
the output of:
$ chktex main.tex
is:
ChkTeX v1.6.4 - Copyright 1995-96 Jens T. Berger Thielemann.
chktex: WARNING -- Unable to open the TeX file `patt'.
Warning 27 in main.tex line 3: Could not execute LaTeX command.
\input{part}
^^^^^^
No errors printed; One warning printed; No user suppressed warnings printed.
But it should be:
ChkTeX v1.6.4 - Copyright 1995-96 Jens T. Berger Thielemann.
Warning 1 in part.tex line 2: Command terminated with space.
A \dots B
^
No errors printed; One warning printed; No user suppressed warnings printed.
I checked the source code of version 1.6.4 of chktex, and found that on line 221 of file FindErrs.c, the following call is performed:
strcpy(OrigDest, OrigDest + 1);
According to the man page of strcpy(3), the src and dst strings should not overlap, so the results are undefined. When I upgraded glibc to version 2.12.2, the bug actually occurred.
I include a patch which replaces the call for an alternative:
ShiftLeftOne(OrigDest);
defined as
static void ShiftLeftOne(char *Buf)
{
char *P;
for (P = Buf + 1; *P; ++P)
(P - 1) = P;
*(P - 1) = '\0';
}
After recompiling, the bug was solved.
|