memcmp(3) Library Functions Manual memcmp(3) memcmp -- C (libc, -lc) #include int memcmp(const void s1[.n], const void s2[.n], size_t n); memcmp() n ( unsigned char) s1 s2. memcmp() , , n s1 , , n s2. , , ( unsigned char) s1 s2. n , . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |memcmp() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ C11, POSIX.1-2008. POSIX.1-2001, C89, SVr4, 4.3BSD. CAVEATS Do not use memcmp() to compare confidential data, such as cryptographic secrets, because the CPU time required for the comparison depends on the contents of the addresses compared, this function is subject to timing-based side-channel attacks. In such cases, a function that performs comparisons in deterministic time, depending only on n (the quantity of bytes compared) is required. Some operating systems provide such a function (e.g., NetBSD's consttime_memequal()), but no such function is specified in POSIX. On Linux, you may need to implement such a function yourself. bstring(3), strcasecmp(3), strcmp(3), strcoll(3), strncasecmp(3), strncmp(3), wmemcmp(3) () aereiae , Alexey , Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , ITriskTI , Max Is , Yuri Kozlov , ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . memcmp(3)