diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2012-10-20 15:28:42 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2012-10-20 15:28:42 +0200 |
commit | cab4f71ebd565c2f7dc0f8d4987785926202bcde (patch) | |
tree | 01fd4bffe8404792fd423c1a72c2a559340eafe5 /lib-src/make-docfile.c | |
parent | c95a42666388351563df91910a4fe791c12c7a1e (diff) |
* make-docfile.c (scan_lisp_file): Add bounds checking.
Diffstat (limited to 'lib-src/make-docfile.c')
-rw-r--r-- | lib-src/make-docfile.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 555a563d74..2f04f1c96f 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; |