diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-07-28 08:40:23 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2015-07-28 08:40:23 +0000 |
commit | 50aad573ddce31e078b3e5cd8ff81d4a4412a13b (patch) | |
tree | bef795010110cb8572e412938a25fcc837b0ae9d | |
parent | 83c64f10045f775f72283696d986a0311454a453 (diff) |
pdfTeX: No reason to use 'long' for 32-bit integers
git-svn-id: svn://tug.org/texlive/trunk@37978 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ptexmac.h | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writettf.c | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writettf.h | 6 |
4 files changed, 14 insertions, 6 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index c9ca22de224..9e4439dec7b 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,9 @@ +2015-07-28 Peter Breitenlohner <peb@mppmu.mpg.de> + + * ptexmac.h: Avoid possible integer overflow. + * writettf.h: No reason to use 'long' for 32-bit integers. + * writettf.c: No reason to use the (possibly 64-bit) 'integer'. + 2015-07-10 Peter Breitenlohner <peb@mppmu.mpg.de> * am/pdftex.am, am/pdftosrc.am, am/ttf2afm.am: Dependencies for diff --git a/Build/source/texk/web2c/pdftexdir/ptexmac.h b/Build/source/texk/web2c/pdftexdir/ptexmac.h index a2387935979..d60ad86c349 100644 --- a/Build/source/texk/web2c/pdftexdir/ptexmac.h +++ b/Build/source/texk/web2c/pdftexdir/ptexmac.h @@ -113,6 +113,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. T##_limit *= 2; \ if ((unsigned)(T##_ptr - T##_array + (n)) > (unsigned)(T##_limit)) \ T##_limit = T##_ptr - T##_array + (n); \ + if ((unsigned)(T##_limit) > INT_MAX) \ + pdftex_fail(#T "_array exceeds size limit"); \ xretalloc(T##_array, T##_limit, T##_entry); \ T##_ptr = T##_array + last_ptr_index; \ } \ diff --git a/Build/source/texk/web2c/pdftexdir/writettf.c b/Build/source/texk/web2c/pdftexdir/writettf.c index ab68813a3c9..4ae5092e6b9 100644 --- a/Build/source/texk/web2c/pdftexdir/writettf.c +++ b/Build/source/texk/web2c/pdftexdir/writettf.c @@ -921,7 +921,7 @@ static void ttf_write_dirtab(void) dirtab_entry *tab; TTF_ULONG i, k; char *p; - const integer save_offset = ttf_offset(); + const uint32_t save_offset = ttf_offset(); ttf_seek_outbuf(TABDIR_OFF); if (is_subsetted(fd_cur->fm)) { for (i = 0; i < DEFAULT_NTABS; i++) { @@ -946,7 +946,7 @@ static void ttf_write_dirtab(void) /* adjust checkSumAdjustment */ tmp_ulong = 0; checksum = 0; - for (p = fb_array, i = 0; i < (unsigned) save_offset;) { + for (p = fb_array, i = 0; i < save_offset;) { tmp_ulong = (tmp_ulong << 8) + *p++; i++; if (i % 4 == 0) { @@ -955,7 +955,7 @@ static void ttf_write_dirtab(void) } } if (i % 4 != 0) { - pdftex_warn("font length is not a multiple of 4 (%li)", i); + pdftex_warn("font length is not a multiple of 4 (%d)", i); checksum <<= 8 * (4 - i % 4); } k = 0xB1B0AFBA - checksum; diff --git a/Build/source/texk/web2c/pdftexdir/writettf.h b/Build/source/texk/web2c/pdftexdir/writettf.h index 7c627832833..dc951f2ab83 100644 --- a/Build/source/texk/web2c/pdftexdir/writettf.h +++ b/Build/source/texk/web2c/pdftexdir/writettf.h @@ -21,9 +21,9 @@ typedef signed char TTF_CHAR; typedef unsigned char TTF_BYTE; typedef signed short TTF_SHORT; typedef unsigned short TTF_USHORT; -typedef signed long TTF_LONG; -typedef unsigned long TTF_ULONG; -typedef unsigned long TTF_FIXED; +typedef int32_t TTF_LONG; +typedef uint32_t TTF_ULONG; +typedef uint32_t TTF_FIXED; typedef unsigned short TTF_FUNIT; typedef signed short TTF_FWORD; typedef unsigned short TTF_UFWORD; |