From 1b4f316651096f0ef9301b4ffde4816a08a54ab5 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 7 Apr 2015 18:43:15 -0700 Subject: Fix UB in ResourceTable::stringToInt. Was here because UBsan found integer overflow in the parsing for hex numbers, since hex numbers here are actually unsigned but assigned to a signed integer. Also fixes a number of missing error conditions. Change-Id: Iaea576daedfc6c75521cde02de3fe9dd0198a3b7 --- include/androidfw/ResourceTypes.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h index 8673219..ff2c6d1 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -372,7 +372,8 @@ struct Res_value }; // The data for this item, as interpreted according to dataType. - uint32_t data; + typedef uint32_t data_type; + data_type data; void copyFrom_dtoh(const Res_value& src); }; @@ -1502,6 +1503,8 @@ private: KeyedVector mEntries; }; +bool U16StringToInt(const char16_t* s, size_t len, Res_value* outValue); + /** * Convenience class for accessing data in a ResTable resource. */ -- cgit v1.1