GNU bug report logs - #52438
29.0.50; [PATCH] Fix off-by-one error in etags.c TeX support

Previous Next

Package: emacs;

Reported by: David Fussner <dfussner <at> googlemail.com>

Date: Sat, 11 Dec 2021 18:58:01 UTC

Severity: normal

Tags: moreinfo, patch

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 52438 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: David Fussner <dfussner <at> googlemail.com>
Cc: 52438 <at> debbugs.gnu.org
Subject: Re: bug#52438: 29.0.50; [PATCH] Fix off-by-one error in etags.c TeX
 support
Date: Sun, 12 Dec 2021 06:41:43 +0100
David Fussner <dfussner <at> googlemail.com> writes:

> The etags program reliably crashes for me when running the test suite in
> test/manual/etags, but you need to have a long-enough TEXTAGS
> environment variable to make it happen.  On my 32-bit GNU/Linux machine,
> going to that directory and running:
>
> TEXTAGS="A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X" make check
>
> crashes the program before it finishes the first run, that is, before it
> stops because the test suite itself fails. 

I'm not able to reproduce the issue on my 64-bit Debian system, but
reading the code, I think your analysis of the problem sounds correct.
The patch seemed slightly confusing, though, so I rewrote it a bit.
Could you check whether this version also fixes the problem?


diff --git a/lib-src/etags.c b/lib-src/etags.c
index bd4d4fcf53..ba66eeede4 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -5773,7 +5773,7 @@ TeX_commands (FILE *inf)
 TEX_decode_env (const char *evarname, const char *defenv)
 {
   const char *env, *p;
-  ptrdiff_t len;
+  ptrdiff_t len = 1;
 
   /* Append default string to environment. */
   env = getenv (evarname);
@@ -5782,8 +5782,13 @@ TEX_decode_env (const char *evarname, const char *defenv)
   else
     env = concat (env, defenv, "");
 
+  /* If the environment variable starts with a colon, increase the
+     length of the token table.  */
+  if (!strneq (env, ":", 1))
+    len++;
+
   /* Allocate a token table */
-  for (len = 1, p = env; (p = strchr (p, ':')); )
+  for (p = env; (p = strchr (p, ':')); )
     if (*++p)
       len++;
   TEX_toktab = xnew (len, linebuffer);


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 159 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.