Merge pull request #20413 from poettering/mempmen

add and use mempmem_safe()
This commit is contained in:
Luca Boccassi
2021-08-10 20:31:36 +01:00
committed by GitHub
4 changed files with 24 additions and 14 deletions
+10
View File
@@ -71,6 +71,16 @@ static inline void *memmem_safe(const void *haystack, size_t haystacklen, const
return memmem(haystack, haystacklen, needle, needlelen);
}
static inline void *mempmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
const uint8_t *p;
p = memmem_safe(haystack, haystacklen, needle, needlelen);
if (!p)
return NULL;
return (uint8_t*) p + needlelen;
}
#if HAVE_EXPLICIT_BZERO
static inline void* explicit_bzero_safe(void *p, size_t l) {
if (l > 0)