From: Andreas Schwab Date: Sat, 20 Oct 2012 13:28:42 +0000 (+0200) Subject: * make-docfile.c (scan_lisp_file): Add bounds checking. X-Git-Tag: emacs-24.2.90~211^2~26 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cab4f71ebd565c2f7dc0f8d4987785926202bcde;p=emacs.git * make-docfile.c (scan_lisp_file): Add bounds checking. --- 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 + + * make-docfile.c (scan_lisp_file): Add bounds checking. + 2012-10-20 Eli Zaretskii 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;