emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110604: * make-docfile.c (scan_lisp_


From: Andreas Schwab
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110604: * make-docfile.c (scan_lisp_file): Add bounds checking.
Date: Sat, 20 Oct 2012 15:28:42 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110604
committer: Andreas Schwab <address@hidden>
branch nick: emacs
timestamp: Sat 2012-10-20 15:28:42 +0200
message:
  * make-docfile.c (scan_lisp_file): Add bounds checking.
modified:
  lib-src/ChangeLog
  lib-src/make-docfile.c
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2012-10-20 10:01:19 +0000
+++ b/lib-src/ChangeLog 2012-10-20 13:28:42 +0000
@@ -1,3 +1,7 @@
+2012-10-20  Andreas Schwab  <address@hidden>
+
+       * make-docfile.c (scan_lisp_file): Add bounds checking.
+
 2012-10-20  Eli Zaretskii  <address@hidden>
 
        Prevent silent omission of doc strings from uncompile Lisp files.

=== modified file 'lib-src/make-docfile.c'
--- a/lib-src/make-docfile.c    2012-10-20 10:01:19 +0000
+++ b/lib-src/make-docfile.c    2012-10-20 13:28:42 +0000
@@ -1108,24 +1108,25 @@
      follow the conventions of the doc strings expected by this
      function.  These conventions are automatically followed by the
      byte compiler when it produces the .elc files.  */
-  static struct {
-    const char *fn;
-    size_t fl;
-  } uncompiled[] = {
-    { "loaddefs.el", sizeof("loaddefs.el") - 1 },
-    { "loadup.el", sizeof("loadup.el") - 1 },
-    { "charprop.el", sizeof("charprop.el") - 1 }
-  };
+  static const char *const uncompiled[] =
+    {
+      "loaddefs.el",
+      "loadup.el",
+      "charprop.el"
+    };
   int i, match;
   size_t flen = strlen (filename);
 
   if (generate_globals)
     fatal ("scanning lisp file when -g specified", 0);
-  if (!strcmp (filename + flen - 3, ".el"))
+  if (flen > 3 && !strcmp (filename + flen - 3, ".el"))
     {
-      for (i = 0, match = 0; i < sizeof(uncompiled)/sizeof(uncompiled[0]); i++)
+      for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]);
+          i++)
        {
-         if (!strcmp (filename + flen - uncompiled[i].fl, uncompiled[i].fn))
+         if (strlen (uncompiled[i]) <= flen
+             && !strcmp (filename + flen - strlen (uncompiled[i]),
+                         uncompiled[i]))
            {
              match = 1;
              break;


reply via email to

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