[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Feb 23 23:51:49 UTC 2018
configure.ac | 2 +
src/Makefile.am | 4 +-
src/harfbuzz-config.cmake.in | 82 +++++++++++++++++++++++++++++++++++++++++++
src/hb-open-file-private.hh | 18 +++++----
src/hb-open-type-private.hh | 3 +
5 files changed, 99 insertions(+), 10 deletions(-)
New commits:
commit ec2538c8803be254b6e09ca0ea724b07c35126da
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Feb 23 15:51:26 2018 -0800
[subset] Fix checksum calc out-of-bounds access
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 88ce65a4..701935b7 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -133,32 +133,34 @@ typedef struct OffsetTable
unsigned int table_count)
{
TRACE_SERIALIZE (this);
- /* alloc 12 for the OTHeader */
+ /* Alloc 12 for the OTHeader. */
if (unlikely (!c->extend_min (*this))) return_trace (false);
- /* write sfntVersion (bytes 0..3) */
+ /* Write sfntVersion (bytes 0..3) */
sfnt_version.set (sfnt_tag);
- /* take space for numTables, searchRange, entrySelector, RangeShift
+ /* Take space for numTables, searchRange, entrySelector, RangeShift
* and the TableRecords themselves
*/
if (unlikely (!tables.serialize (c, table_count))) return_trace (false);
- /* write OffsetTables, alloc for and write actual table blobs */
+ /* Write OffsetTables, alloc for and write actual table blobs. */
for (unsigned int i = 0; i < table_count; i++)
{
TableRecord &rec = tables.array[i];
hb_blob_t *blob = blobs[i];
rec.tag.set (tags[i]);
rec.length.set (hb_blob_get_length (blob));
- rec.checkSum.set_for_data (hb_blob_get_data (blob, nullptr), rec.length);
rec.offset.serialize (c, this);
- // take room for the table
+ /* Allocate room for the table. */
void *p = c->allocate_size<void> (rec.length);
+ const char *start = (const char *) p;
if (unlikely (!p)) {return false;}
- /* copy the actual table */
+ /* copy the actual table. */
memcpy (p, hb_blob_get_data (blob, nullptr), rec.length);
- /* 4-byte allignment */
+ /* 4-byte allignment. */
if (rec.length % 4)
p = c->allocate_size<void> (4 - rec.length % 4);
+ const char *end = (const char *) c->head;
+ rec.checkSum.set_for_data (start, end - start);
}
tags += table_count;
blobs += table_count;
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 54eda4c5..f5c20bcb 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -762,7 +762,8 @@ struct CheckSum : HBUINT32
static inline uint32_t CalcTableChecksum (const HBUINT32 *Table, uint32_t Length)
{
uint32_t Sum = 0L;
- const HBUINT32 *EndPtr = Table+((Length+3) & ~3) / HBUINT32::static_size;
+ assert (0 == (Length & 3));
+ const HBUINT32 *EndPtr = Table + Length / HBUINT32::static_size;
while (Table < EndPtr)
Sum += *Table++;
commit d38f37b2e37942a3fd13cd753c8b8587a06c0f3a
Author: Ben Boeckel <mathstuf at users.noreply.github.com>
Date: Fri Feb 23 16:55:53 2018 -0500
autoconf: provide a harfbuzz-config for use from CMake (#822)
diff --git a/configure.ac b/configure.ac
index 8c3ab202..eee2568d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,7 @@ if $have_gobject; then
AC_SUBST(GLIB_MKENUMS)
fi
AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject)
+AC_SUBST(have_gobject)
dnl ===========================================================================
@@ -491,6 +492,7 @@ AC_CONFIG_FILES([
Makefile
src/Makefile
src/hb-version.h
+src/harfbuzz-config.cmake
src/hb-ucdn/Makefile
util/Makefile
test/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 769a8252..c4d5fb85 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -156,7 +156,9 @@ pkginclude_HEADERS = $(HBHEADERS)
nodist_pkginclude_HEADERS = $(HBNODISTHEADERS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = harfbuzz.pc
-EXTRA_DIST += harfbuzz.pc.in
+cmakedir = $(libdir)/cmake/harfbuzz
+cmake_DATA = harfbuzz-config.cmake
+EXTRA_DIST += harfbuzz.pc.in harfbuzz-config.cmake.in
lib_LTLIBRARIES += libharfbuzz-subset.la
libharfbuzz_subset_la_SOURCES = $(HB_SUBSET_sources)
diff --git a/src/harfbuzz-config.cmake.in b/src/harfbuzz-config.cmake.in
new file mode 100644
index 00000000..87b15721
--- /dev/null
+++ b/src/harfbuzz-config.cmake.in
@@ -0,0 +1,82 @@
+# Set these variables so that the `${prefix}/lib` expands to something we can
+# remove.
+set(_harfbuzz_remove_string "REMOVE_ME")
+set(exec_prefix "${_harfbuzz_remove_string}")
+set(prefix "${_harfbuzz_remove_string}")
+
+# Compute the installation prefix by stripping components from our current
+# location.
+get_filename_component(_harfbuzz_prefix "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
+get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY)
+set(_harfbuzz_libdir "@libdir@")
+string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_libdir "${_harfbuzz_libdir}")
+set(_harfbuzz_libdir_iter "${_harfbuzz_libdir}")
+while (_harfbuzz_libdir_iter)
+ get_filename_component(_harfbuzz_libdir_iter "${_harfbuzz_libdir_iter}" DIRECTORY)
+ get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY)
+endwhile ()
+unset(_harfbuzz_libdir_iter)
+
+# Get the include subdir.
+set(_harfbuzz_includedir "@includedir@")
+string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_includedir "${_harfbuzz_includedir}")
+
+# Extract version information from libtool.
+set(_harfbuzz_version_info "@HB_LIBTOOL_VERSION_INFO@")
+string(REPLACE ":" ";" _harfbuzz_version_info "${_harfbuzz_version_info}")
+list(GET _harfbuzz_version_info 0
+ _harfbuzz_current)
+list(GET _harfbuzz_version_info 1
+ _harfbuzz_revision)
+list(GET _harfbuzz_version_info 2
+ _harfbuzz_age)
+unset(_harfbuzz_version_info)
+
+if (APPLE)
+ set(_harfbuzz_lib_suffix ".0${CMAKE_SHARED_LIBRARY_SUFFIX}")
+elseif (UNIX)
+ set(_harfbuzz_lib_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}.0.${_harfbuzz_current}.${_harfbuzz_revision}")
+else ()
+ # Unsupported.
+ set(harfbuzz_FOUND 0)
+endif ()
+
+# Add the libraries.
+add_library(harfbuzz::harfbuzz SHARED IMPORTED)
+set_target_properties(harfbuzz::harfbuzz PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
+ IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz${_harfbuzz_lib_suffix}")
+
+add_library(harfbuzz::icu SHARED IMPORTED)
+set_target_properties(harfbuzz::icu PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
+ INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
+ IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-icu${_harfbuzz_lib_suffix}")
+
+add_library(harfbuzz::subset SHARED IMPORTED)
+set_target_properties(harfbuzz::subset PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
+ INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
+ IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-subset${_harfbuzz_lib_suffix}")
+
+# Only add the gobject library if it was built.
+set(_harfbuzz_have_gobject "@have_gobject@")
+if (_harfbuzz_have_gobject)
+ add_library(harfbuzz::gobject SHARED IMPORTED)
+ set_target_properties(harfbuzz::gobject PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
+ INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
+ IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-gobject${_harfbuzz_lib_suffix}")
+endif ()
+
+# Clean out variables we used in our scope.
+unset(_harfbuzz_lib_suffix)
+unset(_harfbuzz_current)
+unset(_harfbuzz_revision)
+unset(_harfbuzz_age)
+unset(_harfbuzz_includedir)
+unset(_harfbuzz_libdir)
+unset(_harfbuzz_prefix)
+unset(exec_prefix)
+unset(prefix)
+unset(_harfbuzz_remove_string)
More information about the HarfBuzz
mailing list