mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
LibC: Expose AK::timing_safe_compare via timingsafe_memcmp(..)
Ports / other userland often needs such an implementation to function. Lets expose `AK::timing_safe_compare` under the same name used used in OpenBSD / FreeBSD / Solaris and other projects.
This commit is contained in:
parent
0a5321b3f9
commit
01bd3c5563
2 changed files with 8 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Brian Gianforcaro <bgianf@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -121,6 +122,11 @@ int memcmp(const void* v1, const void* v2, size_t n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int timingsafe_memcmp(const void* b1, const void* b2, size_t len)
|
||||
{
|
||||
return AK::timing_safe_compare(b1, b2, len) ? 1 : 0;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcpy.html
|
||||
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue