diff options
author | Nick Bray <ncbray@google.com> | 2018-10-31 10:39:41 -0700 |
---|---|---|
committer | Nick Bray <ncbray@google.com> | 2018-10-31 10:39:41 -0700 |
commit | 27748e24c1a1fbfb2919817333b6270ace62c16c (patch) | |
tree | e78593bde7eedd8f39dce50eba8cb3fd4a8fbb47 | |
parent | 35df5144c069aae2e958af0531bc137d79034d35 (diff) | |
download | gatekeeper-27748e24c1a1fbfb2919817333b6270ace62c16c.tar.gz |
Replace htonl with htobe32.android-wear-8.0.0_r2android-q-preview-6android-q-preview-5android-q-preview-4android-q-preview-2.5android-q-preview-1android-o-mr1-iot-release-smart-display-r9android-o-mr1-iot-release-smart-display-r8android-o-mr1-iot-release-smart-display-r5android-o-mr1-iot-release-smart-display-r40.1Jandroid-o-mr1-iot-release-smart-display-r4android-o-mr1-iot-release-smart-display-r39android-o-mr1-iot-release-smart-display-r30android-o-mr1-iot-release-smart-display-r22android-o-mr1-iot-release-smart-display-r14android-o-mr1-iot-release-smart-clock-r6android-o-mr1-iot-release-smart-clock-r2android-o-mr1-iot-release-smart-clock-fsiandroid-o-mr1-iot-release-smart-clock-fcsandroid-o-mr1-iot-release-cube_r2android-o-mr1-iot-release-cube-fsiandroid-o-mr1-iot-release-cube-fcsandroid-o-mr1-iot-release-1.0.8android-o-mr1-iot-release-1.0.7android-o-mr1-iot-release-1.0.10android-n-iot-release-ihome-igv1nougat-iot-release
htonl is supposed to be defined in arpa/inet.h, not endian.h. This code
compiles thanks to non-standard endian.h. Being stricter helps make it
more portable.
It would be possible to switch header files instead of switching
functions, but htobe64 is used elsewhere in the code. There is no
"network" function for 64-bit types. It seems slightly cleaner to be
consistent naming things "big endian" rather than mixing terms.
Bug: 110161494
Change-Id: I9b66b967c587d7c0853631d1fbb12e2e41c7d1b2
-rw-r--r-- | gatekeeper.cpp | 2 | ||||
-rw-r--r-- | tests/gatekeeper_device_test.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/gatekeeper.cpp b/gatekeeper.cpp index 052c4db..1d71684 100644 --- a/gatekeeper.cpp +++ b/gatekeeper.cpp @@ -232,7 +232,7 @@ void GateKeeper::MintAuthToken(UniquePtr<uint8_t> *auth_token, uint32_t *length, token->challenge = challenge; token->user_id = user_id; token->authenticator_id = authenticator_id; - token->authenticator_type = htonl(HW_AUTH_PASSWORD); + token->authenticator_type = htobe32(HW_AUTH_PASSWORD); token->timestamp = htobe64(timestamp); const uint8_t *auth_token_key = NULL; diff --git a/tests/gatekeeper_device_test.cpp b/tests/gatekeeper_device_test.cpp index 0e7ace6..f166ca8 100644 --- a/tests/gatekeeper_device_test.cpp +++ b/tests/gatekeeper_device_test.cpp @@ -98,7 +98,7 @@ TEST_F(GateKeeperDeviceTest, EnrollAndVerify) { hat = reinterpret_cast<hw_auth_token_t *>(auth_token); ASSERT_EQ(HW_AUTH_TOKEN_VERSION, hat->version); - ASSERT_EQ(htonl(HW_AUTH_PASSWORD), hat->authenticator_type); + ASSERT_EQ(htobe32(HW_AUTH_PASSWORD), hat->authenticator_type); } TEST_F(GateKeeperDeviceTest, EnrollAndVerifyTimeout) { |