From: Po Lu Date: Sat, 3 Aug 2024 09:34:18 +0000 (+0800) Subject: Revert "Remove redundant byte-swapping boundary" X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c98a8b117a2c93d09bc336561242ac4b6bf8f192;p=emacs.git Revert "Remove redundant byte-swapping boundary" This reverts commit daefd6771a4879bb8e71ea67f69522700155df01. * src/sfnt.c (sfnt_read_OS_2_table): Restore realignment after s_family_class, as it occupies byte 32, not 34. Reported by Pip Cet . (cherry picked from commit 8d073823c61017c581a18853c89ec84432018d60) --- diff --git a/src/sfnt.c b/src/sfnt.c index 11670f1dd5c..34ff6964c31 100644 --- a/src/sfnt.c +++ b/src/sfnt.c @@ -16606,10 +16606,10 @@ sfnt_read_OS_2_table (int fd, struct sfnt_offset_subtable *subtable) OS_2 = xmalloc (sizeof *OS_2); - /* Read data into the structure. */ + /* Read data up to the end of `panose'. */ - wanted = SFNT_ENDOF (struct sfnt_OS_2_table, fs_last_char_index, - uint16_t); + wanted = SFNT_ENDOF (struct sfnt_OS_2_table, panose, + unsigned char[10]); rc = read (fd, OS_2, wanted); if (rc == -1 || rc != wanted) @@ -16636,6 +16636,20 @@ sfnt_read_OS_2_table (int fd, struct sfnt_offset_subtable *subtable) sfnt_swap16 (&OS_2->y_strikeout_size); sfnt_swap16 (&OS_2->y_strikeout_position); sfnt_swap16 (&OS_2->s_family_class); + + /* Read fields between ul_unicode_range and fs_last_char_index. */ + wanted = (SFNT_ENDOF (struct sfnt_OS_2_table, fs_last_char_index, + uint16_t) + - offsetof (struct sfnt_OS_2_table, ul_unicode_range)); + rc = read (fd, &OS_2->ul_unicode_range, wanted); + + if (rc == -1 || rc != wanted) + { + xfree (OS_2); + return NULL; + } + + /* Swap the remainder and return the table. */ sfnt_swap32 (&OS_2->ul_unicode_range[0]); sfnt_swap32 (&OS_2->ul_unicode_range[1]); sfnt_swap32 (&OS_2->ul_unicode_range[2]); diff --git a/src/sfnt.h b/src/sfnt.h index ecc3876b394..444b1dfe427 100644 --- a/src/sfnt.h +++ b/src/sfnt.h @@ -1395,6 +1395,8 @@ struct sfnt_OS_2_table /* Microsoft ``panose'' classification. */ unsigned char panose[10]; + /* Alignment boundary! */ + /* Unicode range specification. */ uint32_t ul_unicode_range[4];