diff options
| author | Philipp Stephani | 2019-10-05 13:00:08 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2019-10-05 13:00:08 +0200 |
| commit | 66839a74bb74efa16f9f531e93d58cadf6ab7196 (patch) | |
| tree | 4daccc7d0beff39fb565cdc6e28de9b7b1720d32 | |
| parent | 7d8548a0110560c558d79c23ce2c2f9da79ab68b (diff) | |
| download | emacs-66839a74bb74efa16f9f531e93d58cadf6ab7196.tar.gz emacs-66839a74bb74efa16f9f531e93d58cadf6ab7196.zip | |
* src/fns.c (Flocale_info): Avoid fixnum overflow under ASan.
| -rw-r--r-- | src/fns.c | 10 |
1 files changed, 8 insertions, 2 deletions
| @@ -3176,8 +3176,14 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 3176 | # endif | 3176 | # endif |
| 3177 | # ifdef HAVE_LANGINFO__NL_PAPER_WIDTH | 3177 | # ifdef HAVE_LANGINFO__NL_PAPER_WIDTH |
| 3178 | if (EQ (item, Qpaper)) | 3178 | if (EQ (item, Qpaper)) |
| 3179 | return list2i ((intptr_t) nl_langinfo (_NL_PAPER_WIDTH), | 3179 | /* We have to cast twice here: first to a correctly-sized integer, |
| 3180 | (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT)); | 3180 | then to int, because that's what nl_langinfo is documented to |
| 3181 | return for _NO_PAPER_{WIDTH,HEIGHT}. The first cast doesn't | ||
| 3182 | suffice because it could overflow an Emacs fixnum. This can | ||
| 3183 | happen when running under ASan, which fills allocated but | ||
| 3184 | uninitialized memory with 0xBE bytes. */ | ||
| 3185 | return list2i ((int) (intptr_t) nl_langinfo (_NL_PAPER_WIDTH), | ||
| 3186 | (int) (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT)); | ||
| 3181 | # endif | 3187 | # endif |
| 3182 | #endif /* HAVE_LANGINFO_CODESET*/ | 3188 | #endif /* HAVE_LANGINFO_CODESET*/ |
| 3183 | return Qnil; | 3189 | return Qnil; |