diff options
| author | Andreas Schwab | 2012-10-20 15:28:42 +0200 |
|---|---|---|
| committer | Andreas Schwab | 2012-10-20 15:28:42 +0200 |
| commit | cab4f71ebd565c2f7dc0f8d4987785926202bcde (patch) | |
| tree | 01fd4bffe8404792fd423c1a72c2a559340eafe5 /lib-src/make-docfile.c | |
| parent | c95a42666388351563df91910a4fe791c12c7a1e (diff) | |
| download | emacs-cab4f71ebd565c2f7dc0f8d4987785926202bcde.tar.gz emacs-cab4f71ebd565c2f7dc0f8d4987785926202bcde.zip | |
* 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 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) | |||
| 1108 | follow the conventions of the doc strings expected by this | 1108 | follow the conventions of the doc strings expected by this |
| 1109 | function. These conventions are automatically followed by the | 1109 | function. These conventions are automatically followed by the |
| 1110 | byte compiler when it produces the .elc files. */ | 1110 | byte compiler when it produces the .elc files. */ |
| 1111 | static struct { | 1111 | static const char *const uncompiled[] = |
| 1112 | const char *fn; | 1112 | { |
| 1113 | size_t fl; | 1113 | "loaddefs.el", |
| 1114 | } uncompiled[] = { | 1114 | "loadup.el", |
| 1115 | { "loaddefs.el", sizeof("loaddefs.el") - 1 }, | 1115 | "charprop.el" |
| 1116 | { "loadup.el", sizeof("loadup.el") - 1 }, | 1116 | }; |
| 1117 | { "charprop.el", sizeof("charprop.el") - 1 } | ||
| 1118 | }; | ||
| 1119 | int i, match; | 1117 | int i, match; |
| 1120 | size_t flen = strlen (filename); | 1118 | size_t flen = strlen (filename); |
| 1121 | 1119 | ||
| 1122 | if (generate_globals) | 1120 | if (generate_globals) |
| 1123 | fatal ("scanning lisp file when -g specified", 0); | 1121 | fatal ("scanning lisp file when -g specified", 0); |
| 1124 | if (!strcmp (filename + flen - 3, ".el")) | 1122 | if (flen > 3 && !strcmp (filename + flen - 3, ".el")) |
| 1125 | { | 1123 | { |
| 1126 | for (i = 0, match = 0; i < sizeof(uncompiled)/sizeof(uncompiled[0]); i++) | 1124 | for (i = 0, match = 0; i < sizeof (uncompiled) / sizeof (uncompiled[0]); |
| 1125 | i++) | ||
| 1127 | { | 1126 | { |
| 1128 | if (!strcmp (filename + flen - uncompiled[i].fl, uncompiled[i].fn)) | 1127 | if (strlen (uncompiled[i]) <= flen |
| 1128 | && !strcmp (filename + flen - strlen (uncompiled[i]), | ||
| 1129 | uncompiled[i])) | ||
| 1129 | { | 1130 | { |
| 1130 | match = 1; | 1131 | match = 1; |
| 1131 | break; | 1132 | break; |