diff options
3 files changed, 45 insertions, 3 deletions
diff --git a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog index b8600569172..1e921b92a5c 100644 --- a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog +++ b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/ChangeLog @@ -1,3 +1,9 @@ +2010-05-20 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-04-strcpy-bug (new): Bug fixes: + (GetLTXArg): Avoid strcpy() with overlapping args. + (PreProcess): Do not access Buf[-1]. + 2010-05-06 Peter Breitenlohner <peb@mppmu.mpg.de> * patch-02-bug (new): Bug fix diff --git a/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-04-strcpy-bug b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-04-strcpy-bug new file mode 100644 index 00000000000..ed744e02d4f --- /dev/null +++ b/Build/source/utils/chktex/chktex-1.6.4-PATCHES/patch-04-strcpy-bug @@ -0,0 +1,35 @@ + Must not use strcpy() for overlapping strings. + + Do not access Buf[-1]. + +diff -ur chktex-1.6.4.orig/FindErrs.c chktex-1.6.4/FindErrs.c +--- chktex-1.6.4.orig/FindErrs.c 2010-05-02 22:12:06.000000000 +0200 ++++ chktex-1.6.4/FindErrs.c 2010-05-20 16:28:35.822091392 +0200 +@@ -218,7 +218,7 @@ + + if (Retval && (*OrigDest == '{') && (Until == GET_STRIP_TOKEN)) + { +- strcpy(OrigDest, OrigDest + 1); ++ memmove(OrigDest, OrigDest + 1, strlen(OrigDest)); + OrigDest[strlen(OrigDest) - 1] = 0; + } + break; +@@ -266,7 +266,7 @@ + + while ((TmpPtr = strchr(TmpPtr, '%'))) + { +- if (TmpPtr[-1] != '\\') ++ if ((TmpPtr == Buf) || (TmpPtr[-1] != '\\')) + { + PSERR(TmpPtr - Buf, 1, emComment); + *TmpPtr = 0; +@@ -1317,7 +1317,8 @@ + * %n - warning Number + * %u - an Underlining line (like the one which appears when using -v1) + * %r - part of line in front of error ('S' - 1) +- * %s - part of line which contains error (String) * %t - part of line after error ('S' + 1) ++ * %s - part of line which contains error (String) ++ * %t - part of line after error ('S' + 1) + */ + + diff --git a/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c b/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c index 5f44a16390d..933bd4567e3 100644 --- a/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c +++ b/Build/source/utils/chktex/chktex-1.6.4/FindErrs.c @@ -218,7 +218,7 @@ static char *GetLTXArg(char *SrcBuf, char *OrigDest, const int Until, if (Retval && (*OrigDest == '{') && (Until == GET_STRIP_TOKEN)) { - strcpy(OrigDest, OrigDest + 1); + memmove(OrigDest, OrigDest + 1, strlen(OrigDest)); OrigDest[strlen(OrigDest) - 1] = 0; } break; @@ -266,7 +266,7 @@ static char *PreProcess(void) while ((TmpPtr = strchr(TmpPtr, '%'))) { - if (TmpPtr[-1] != '\\') + if ((TmpPtr == Buf) || (TmpPtr[-1] != '\\')) { PSERR(TmpPtr - Buf, 1, emComment); *TmpPtr = 0; @@ -1317,7 +1317,8 @@ void PrintStatus(unsigned long Lines) * %n - warning Number * %u - an Underlining line (like the one which appears when using -v1) * %r - part of line in front of error ('S' - 1) - * %s - part of line which contains error (String) * %t - part of line after error ('S' + 1) + * %s - part of line which contains error (String) + * %t - part of line after error ('S' + 1) */ |