From a2a24b22a8ba82b9f2637e7408a83a81c7e8d72f Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 15 May 2017 14:12:48 -0700 Subject: [PATCH 1/2] Force _identityUpdatedAt to stay above 0 --- libraries/avatars/src/AvatarData.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 6992e66f0e..f839a99710 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1538,7 +1538,14 @@ void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityC // use the timestamp from this identity, since we want to honor the updated times in "server clock" // this will overwrite any changes we made locally to this AvatarData's _identityUpdatedAt - _identityUpdatedAt = identity.updatedAt - clockSkew; + // Additionally, ensure that the timestamp that we try to record isn't negative, as + // "_identityUpdatedAt" is an *unsigned* 64-bit integer. Furthermore, negative timestamps + // wouldn't make sense. + if (identity.updatedAt - clockSkew >= 0) { + _identityUpdatedAt = identity.updatedAt - clockSkew; + } else { + _identityUpdatedAt = 0; + } } QByteArray AvatarData::identityByteArray() const { From e492ca9364c8b9f8aae61b09ed5ae4acaa97d4aa Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 15 May 2017 14:55:05 -0700 Subject: [PATCH 2/2] Improve the test - thanks Dave! --- libraries/avatars/src/AvatarData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index f839a99710..efd5158c7d 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1541,7 +1541,7 @@ void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityC // Additionally, ensure that the timestamp that we try to record isn't negative, as // "_identityUpdatedAt" is an *unsigned* 64-bit integer. Furthermore, negative timestamps // wouldn't make sense. - if (identity.updatedAt - clockSkew >= 0) { + if (identity.updatedAt > clockSkew) { _identityUpdatedAt = identity.updatedAt - clockSkew; } else { _identityUpdatedAt = 0;