Merge pull request #7996 from julek-wolfssl/move-mymemmem

memmem is only being used in testing so move it there

Failing test is disabled in: 5be198fa0e
This commit is contained in:
András Fekete
2024-09-20 09:08:44 -04:00
committed by GitHub
5 changed files with 23 additions and 26 deletions

View File

@ -94164,10 +94164,10 @@ static int test_dtls13_basic_connection_id(void)
size_t i;
/* We check if the side included the CID in their output */
#define CLIENT_CID() XMEMMEM(test_ctx.s_buff, test_ctx.s_len, \
client_cid, sizeof(client_cid))
#define SERVER_CID() XMEMMEM(test_ctx.c_buff, test_ctx.c_len, \
server_cid, sizeof(server_cid))
#define CLIENT_CID() mymemmem(test_ctx.s_buff, test_ctx.s_len, \
client_cid, sizeof(client_cid))
#define SERVER_CID() mymemmem(test_ctx.c_buff, test_ctx.c_len, \
server_cid, sizeof(server_cid))
printf("\n");
for (i = 0; i < XELEM_CNT(params) && EXPECT_SUCCESS(); i++) {

View File

@ -3397,25 +3397,6 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
}
#endif
void *mymemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen)
{
size_t i, j;
const char* h = (const char*)haystack;
const char* n = (const char*)needle;
if (needlelen > haystacklen)
return NULL;
for (i = 0; i <= haystacklen - needlelen; i++) {
for (j = 0; j < needlelen; j++) {
if (h[i + j] != n[j])
break;
}
if (j == needlelen)
return (void*)(h + i);
}
return NULL;
}
/* custom memory wrappers */
#ifdef WOLFSSL_NUCLEUS_1_2

View File

@ -4853,4 +4853,23 @@ void DEBUG_WRITE_DER(const byte* der, int derSz, const char* fileName);
#define DTLS_CID_BUFFER_SIZE 256
static WC_MAYBE_UNUSED void *mymemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen)
{
size_t i, j;
const char* h = (const char*)haystack;
const char* n = (const char*)needle;
if (needlelen > haystacklen)
return NULL;
for (i = 0; i <= haystacklen - needlelen; i++) {
for (j = 0; j < needlelen; j++) {
if (h[i + j] != n[j])
break;
}
if (j == needlelen)
return (void*)(h + i);
}
return NULL;
}
#endif /* wolfSSL_TEST_H */

View File

@ -730,7 +730,6 @@ typedef struct w64wrapper {
#define XMEMSET(b,c,l) memset((b),(c),(l))
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
#define XMEMMEM(h,hl,n,nl) mymemmem((h),(hl),(n),(nl))
#define XSTRLEN(s1) strlen((s1))
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))

View File

@ -1203,8 +1203,6 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#ifndef WOLFSSL_LEANPSK
char* mystrnstr(const char* s1, const char* s2, unsigned int n);
#endif
WOLFSSL_API void *mymemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
#ifndef FILE_BUFFER_SIZE
/* default static file buffer size for input, will use dynamic buffer if