texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Avoid crashes in 'handle_block_command'


From: Eli Zaretskii
Subject: branch master updated: Avoid crashes in 'handle_block_command'
Date: Mon, 12 Jul 2021 13:53:24 -0400

This is an automated email from the git hooks/post-receive script.

eliz pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 0c98220  Avoid crashes in 'handle_block_command'
0c98220 is described below

commit 0c98220148d6c4a89f357360c28a4fc890c4666b
Author: Eli Zaretskii <eliz@gnu.org>
AuthorDate: Mon Jul 12 20:51:25 2021 +0300

    Avoid crashes in 'handle_block_command'
    
    * tp/Texinfo/XS/parsetexi/handle_commands.c
    (handle_block_command): Don't let 'memcmp' try accessing memory
    past the end of the input buffer.
---
 ChangeLog                                 |  6 ++++++
 tp/Texinfo/XS/parsetexi/handle_commands.c | 19 +++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ff1f31..654b845 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-07-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * tp/Texinfo/XS/parsetexi/handle_commands.c
+       (handle_block_command): Don't let 'memcmp' try accessing memory
+       past the end of the input buffer.
+
 2021-07-07  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Initial work on LaTeX back-end
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index fa3ce13..39c73c3 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -811,16 +811,19 @@ handle_block_command (ELEMENT *current, char **line_inout,
                 {
                   p += strspn (p, whitespace_chars);
                   /* Check for a comment at the end of the line. */
-                  if (memcmp (p, "@c", 2) == 0)
+                  if (*p)
                     {
-                      p += 2;
-                      if (memcmp (p, "omment", 6) == 0)
-                        p += 7;
-                      if (*p && *p != '@' && !strchr (whitespace_chars, *p))
-                        goto bad_value; /* @c or @comment not terminated. */
+                     if (memcmp (p, "@c", 2) == 0)
+                       {
+                         p += 2;
+                         if (memcmp (p, "omment", 6) == 0)
+                           p += 7;
+                         if (*p && *p != '@' && !strchr (whitespace_chars, *p))
+                           goto bad_value; /* @c or @comment not terminated. */
+                       }
+                     else
+                       goto bad_value; /* Trailing characters on line. */
                     }
-                  else if (*p)
-                    goto bad_value; /* Trailing characters on line. */
                 }
               if (1)
                 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]