mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-22 04:47:34 +00:00
etags had undefined behavior if input files, lines, tags, etc., had more than INT_MAX bytes. Clean up the usage of integer types to fix the overflow errors I found. * admin/merge-gnulib (GNULIB_MODULES): Add mempcpy. * lib-src/etags.c: Include inttypes.h, intprops.h. (memcpyz): New function. Use it to simplify several occurrences of memcpy followed by storing a trailing '\0'. (xnew): Use xnmalloc, to catch overflow on integer multiplication. (xrnew): Change last arg to multiplier. The type is not needed. All callers changed. (node, lineno, charno, linecharno, invalidcharno, make_tag): (pfnote, add_node, number_len, C_symtype, lbz, Makefile_targets) (readline): Use intmax_t for line numbers and character positions, instead of int or long. (linebuffer, make_tag, pfnote, total_size_of_entries, put_entry) (in_word_set, C_symtype, token, cstack, pushclass_above): (popclass_above, write_classname, consider_token, C_entries) (Ruby_functions, Makefile_targets, Lua_functions, TeX_commands) (TeX_decode_env, erlang_func, erlang_attribute, erlang_atom) (substitute, regex_tag_multiline, nocase_tail, readline_interval) (readline, savenstr, concat, etags_getcwd, relative_filename) (linebuffer_setlen): Use ptrdiff_t for object sizes, instead of int or long or unsigned or size_t. (write_classname, C_entries): Avoid sprintf, as the result could exceed INT_MAX bytes and then behavior goes haywire. (main): Use int, instead of unsigned, for argv counts. (get_language_from_filename): Use bool for boolean. (Ruby_functions): Prefer strcpy to memcpy when copying "=". (linebuffer_setlen): Use ‘if’ instead of ‘while’. (memory_full, xnmalloc, xnrealloc): New functions. (xmalloc): Use memory_full, and take a ptrdiff_t instead of a size_t. (xrealloc): Remove; no longer needed. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/mempcpy.c, m4/mempcpy.m4: New files, copied from Gnulib. |
||
|---|---|---|
| .. | ||
| _Noreturn.h | ||
| acl-errno-valid.c | ||
| acl-internal.c | ||
| acl-internal.h | ||
| acl.h | ||
| acl_entries.c | ||
| alloca.in.h | ||
| allocator.c | ||
| allocator.h | ||
| arg-nonnull.h | ||
| at-func.c | ||
| binary-io.c | ||
| binary-io.h | ||
| byteswap.in.h | ||
| c++defs.h | ||
| c-ctype.c | ||
| c-ctype.h | ||
| c-strcase.h | ||
| c-strcasecmp.c | ||
| c-strncasecmp.c | ||
| canonicalize-lgpl.c | ||
| careadlinkat.c | ||
| careadlinkat.h | ||
| cdefs.h | ||
| cloexec.c | ||
| cloexec.h | ||
| close-stream.c | ||
| close-stream.h | ||
| copy-file-range.c | ||
| COPYING | ||
| count-leading-zeros.c | ||
| count-leading-zeros.h | ||
| count-one-bits.c | ||
| count-one-bits.h | ||
| count-trailing-zeros.c | ||
| count-trailing-zeros.h | ||
| diffseq.h | ||
| dirent.in.h | ||
| dirfd.c | ||
| dosname.h | ||
| dtoastr.c | ||
| dtotimespec.c | ||
| dup2.c | ||
| errno.in.h | ||
| euidaccess.c | ||
| execinfo.c | ||
| execinfo.in.h | ||
| explicit_bzero.c | ||
| faccessat.c | ||
| fcntl.c | ||
| fcntl.in.h | ||
| fdopendir.c | ||
| filemode.c | ||
| filemode.h | ||
| filevercmp.c | ||
| filevercmp.h | ||
| fingerprint.c | ||
| fingerprint.h | ||
| flexmember.h | ||
| fpending.c | ||
| fpending.h | ||
| fstatat.c | ||
| fsusage.c | ||
| fsusage.h | ||
| fsync.c | ||
| ftoastr.c | ||
| ftoastr.h | ||
| get-permissions.c | ||
| getdtablesize.c | ||
| getgroups.c | ||
| getloadavg.c | ||
| getopt-cdefs.in.h | ||
| getopt-core.h | ||
| getopt-ext.h | ||
| getopt-pfx-core.h | ||
| getopt-pfx-ext.h | ||
| getopt.c | ||
| getopt.in.h | ||
| getopt1.c | ||
| getopt_int.h | ||
| gettext.h | ||
| gettime.c | ||
| gettimeofday.c | ||
| gnulib.mk.in | ||
| group-member.c | ||
| ieee754.in.h | ||
| ignore-value.h | ||
| intprops.h | ||
| inttypes.in.h | ||
| libc-config.h | ||
| limits.in.h | ||
| localtime-buffer.c | ||
| localtime-buffer.h | ||
| lstat.c | ||
| Makefile.in | ||
| malloca.c | ||
| malloca.h | ||
| md5.c | ||
| md5.h | ||
| memmem.c | ||
| mempcpy.c | ||
| memrchr.c | ||
| min-max.h | ||
| minmax.h | ||
| mkostemp.c | ||
| mktime-internal.h | ||
| mktime.c | ||
| nstrftime.c | ||
| open.c | ||
| openat-die.c | ||
| openat-priv.h | ||
| openat-proc.c | ||
| openat.h | ||
| pathmax.h | ||
| pipe2.c | ||
| pselect.c | ||
| pthread_sigmask.c | ||
| putenv.c | ||
| qcopy-acl.c | ||
| readlink.c | ||
| readlinkat.c | ||
| regcomp.c | ||
| regex.c | ||
| regex.h | ||
| regex_internal.c | ||
| regex_internal.h | ||
| regexec.c | ||
| root-uid.h | ||
| save-cwd.c | ||
| save-cwd.h | ||
| set-permissions.c | ||
| sha1.c | ||
| sha1.h | ||
| sha256.c | ||
| sha256.h | ||
| sha512.c | ||
| sha512.h | ||
| sig2str.c | ||
| sig2str.h | ||
| signal.in.h | ||
| stat-time.c | ||
| stat-time.h | ||
| stdalign.in.h | ||
| stddef.in.h | ||
| stdint.in.h | ||
| stdio-impl.h | ||
| stdio.in.h | ||
| stdlib.in.h | ||
| stpcpy.c | ||
| str-two-way.h | ||
| strftime.h | ||
| string.in.h | ||
| strnlen.c | ||
| strtoimax.c | ||
| strtol.c | ||
| strtoll.c | ||
| symlink.c | ||
| sys_select.in.h | ||
| sys_stat.in.h | ||
| sys_time.in.h | ||
| sys_types.in.h | ||
| tempname.c | ||
| tempname.h | ||
| time-internal.h | ||
| time.in.h | ||
| time_r.c | ||
| time_rz.c | ||
| timegm.c | ||
| timespec-add.c | ||
| timespec-sub.c | ||
| timespec.c | ||
| timespec.h | ||
| u64.c | ||
| u64.h | ||
| unistd.c | ||
| unistd.in.h | ||
| unlocked-io.h | ||
| utimens.c | ||
| utimens.h | ||
| verify.h | ||
| vla.h | ||
| warn-on-use.h | ||
| xalloc-oversized.h | ||