/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
staticvoid FormatUUID(const uint8_t (&aBytes)[16], nsACString& aOut) {
nsID id;
id.m0 = BigEndian::readUint32(&aBytes[0]);
id.m1 = BigEndian::readUint16(&aBytes[4]);
id.m2 = BigEndian::readUint16(&aBytes[6]); // m3 are bytes, we can memcpy without worrying about endianness:
memcpy(id.m3, &aBytes[8], sizeof(id.m3));
char buf[NSID_LENGTH];
id.ToProvidedString(buf); // +1 to skip the "{" that nsID::ToProvidedString always prepends.
aOut.Assign(buf + 1, 36);
}
staticbool ParseUUID(const nsACString& aUUID, uint8_t (&aOut)[16]) { if (aUUID.Length() != 36) { // nsID is too permissive, it accepts UUID with "{" and "}", and it also // accepts trailing junk (bug 2046385). Enforcing the expected length // ensures that we only accept bracketless UUID inputs. returnfalse;
}
nsID id; if (!id.Parse(PromiseFlatCString(aUUID).get())) { returnfalse;
}
BigEndian::writeUint32(&aOut[0], id.m0);
BigEndian::writeUint16(&aOut[4], id.m1);
BigEndian::writeUint16(&aOut[6], id.m2); // m3 are bytes, we can memcpy without worrying about endianness:
memcpy(&aOut[8], id.m3, sizeof(id.m3)); return true;
}
NS_IMETHODIMP KeyedUUIDMapper::GenerateKey(nsTArray<uint8_t>& aKey) {
aKey.SetLength(16); // Intentionally avoids NSS to allow callers to initialize the key early // during browser startup without forced NSS initialization (bug 2050882). if (!GenerateRandomBytesFromOS(aKey.Elements(), aKey.Length())) {
aKey.Clear(); return NS_ERROR_FAILURE;
} return NS_OK;
}
if (BigEndian::readUint64(plaintext + 8) != 0) { // ToUUID only ever fills 8 out of 16 bytes. The other 8 should be 0. // If we find a value with non-zeroes here, then the input UUID is bogus // value that could never have been produced by us. Reject it. return NS_ERROR_INVALID_ARG;
}
uint64_t result = BigEndian::readUint64(plaintext); if (result > kJS_MAX_SAFE_UINTEGER) { // ToUUID rejects inputs beyond kJS_MAX_SAFE_UINTEGER, so we should not // receive it here either. return NS_ERROR_INVALID_ARG;
}
*aResult = result; return NS_OK;
}
} // namespace mozilla
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.