mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +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
Notes:
sideshowbarker
2024-07-17 17:27:47 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/01bd3c5563 Pull-request: https://github.com/SerenityOS/serenity/pull/13021 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling ✅
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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -23,6 +24,7 @@ int strcmp(const char*, const char*);
|
|||
int strncmp(const char*, const char*, size_t);
|
||||
|
||||
int memcmp(const void*, const void*, size_t);
|
||||
int timingsafe_memcmp(const void*, const void*, size_t);
|
||||
void* memcpy(void*, const void*, size_t);
|
||||
void* memmove(void*, const void*, size_t);
|
||||
void* memchr(const void*, int c, size_t);
|
||||
|
|
Loading…
Reference in a new issue