mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
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:
@ -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++) {
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user