summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2012-10-20 15:28:42 +0200
committerAndreas Schwab <schwab@linux-m68k.org>2012-10-20 15:28:42 +0200
commitcab4f71ebd565c2f7dc0f8d4987785926202bcde (patch)
tree01fd4bffe8404792fd423c1a72c2a559340eafe5 /lib-src
parentc95a42666388351563df91910a4fe791c12c7a1e (diff)
downloademacs-cab4f71ebd565c2f7dc0f8d4987785926202bcde.tar.gz
* make-docfile.c (scan_lisp_file): Add bounds checking.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog4
-rw-r--r--lib-src/make-docfile.c23
2 files changed, 16 insertions, 11 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 07fd4658172..02561c4aa3a 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-20 Andreas Schwab <schwab@linux-m68k.org>
+
+ * make-docfile.c (scan_lisp_file): Add bounds checking.
+
2012-10-20 Eli Zaretskii <eliz@gnu.org>
Prevent silent omission of doc strings from uncompile Lisp files.
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 555a563d748..2f04f1c96f3 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -1108,24 +1108,25 @@ scan_lisp_file (const char *filename, const char *mode)
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;