summaryrefslogtreecommitdiffstats
path: root/init/util_test.cpp
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2015-06-18 17:46:54 -0700
committerNick Kralevich <nnk@google.com>2015-06-18 20:11:06 -0700
commitd2104df69b464721a17c21b4cd27931dc3bca612 (patch)
tree832e8d1910ee35aec02ea8bf0019090be82447b3 /init/util_test.cpp
parent53d504f00dea232601e1290c8255274afb0f4256 (diff)
downloadsystem_core-d2104df69b464721a17c21b4cd27931dc3bca612.tar.gz
system_core-d2104df69b464721a17c21b4cd27931dc3bca612.tar.bz2
system_core-d2104df69b464721a17c21b4cd27931dc3bca612.zip
init/util.cpp: don't return a negative unsigned value
android_name_to_id() returns -1U on error, which causes a crash when the following clang options are enabled: -fsanitize=signed-integer-overflow,unsigned-integer-overflow -ftrap-function=abort -fsanitize-undefined-trap-on-error Rather than returning a negative unsigned value (which doesn't make a lot of sense, IMHO), return a positive unsigned value. While we're here, add logging on decode_uid failures. Bug: 21880301 Change-Id: I652e4c1daa07c7494cceca2b4e1656b9158f2604
Diffstat (limited to 'init/util_test.cpp')
-rw-r--r--init/util_test.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/init/util_test.cpp b/init/util_test.cpp
index 5b3ab50b2..228954b44 100644
--- a/init/util_test.cpp
+++ b/init/util_test.cpp
@@ -38,6 +38,6 @@ TEST(util, read_file_success) {
TEST(util, decode_uid) {
EXPECT_EQ(0U, decode_uid("root"));
- EXPECT_EQ(-1U, decode_uid("toot"));
+ EXPECT_EQ(UINT_MAX, decode_uid("toot"));
EXPECT_EQ(123U, decode_uid("123"));
}