Skip to content

Commit d730366

Browse files
committed
memmem is only being used in testing so move it there
1 parent b990840 commit d730366

5 files changed

Lines changed: 23 additions & 26 deletions

File tree

tests/api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94147,10 +94147,10 @@ static int test_dtls13_basic_connection_id(void)
9414794147
size_t i;
9414894148

9414994149
/* We check if the side included the CID in their output */
94150-
#define CLIENT_CID() XMEMMEM(test_ctx.s_buff, test_ctx.s_len, \
94151-
client_cid, sizeof(client_cid))
94152-
#define SERVER_CID() XMEMMEM(test_ctx.c_buff, test_ctx.c_len, \
94153-
server_cid, sizeof(server_cid))
94150+
#define CLIENT_CID() mymemmem(test_ctx.s_buff, test_ctx.s_len, \
94151+
client_cid, sizeof(client_cid))
94152+
#define SERVER_CID() mymemmem(test_ctx.c_buff, test_ctx.c_len, \
94153+
server_cid, sizeof(server_cid))
9415494154

9415594155
printf("\n");
9415694156
for (i = 0; i < XELEM_CNT(params) && EXPECT_SUCCESS(); i++) {

wolfcrypt/src/wc_port.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,25 +3397,6 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
33973397
}
33983398
#endif
33993399

3400-
void *mymemmem(const void *haystack, size_t haystacklen,
3401-
const void *needle, size_t needlelen)
3402-
{
3403-
size_t i, j;
3404-
const char* h = (const char*)haystack;
3405-
const char* n = (const char*)needle;
3406-
if (needlelen > haystacklen)
3407-
return NULL;
3408-
for (i = 0; i <= haystacklen - needlelen; i++) {
3409-
for (j = 0; j < needlelen; j++) {
3410-
if (h[i + j] != n[j])
3411-
break;
3412-
}
3413-
if (j == needlelen)
3414-
return (void*)(h + i);
3415-
}
3416-
return NULL;
3417-
}
3418-
34193400

34203401
/* custom memory wrappers */
34213402
#ifdef WOLFSSL_NUCLEUS_1_2

wolfssl/test.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,4 +4853,23 @@ void DEBUG_WRITE_DER(const byte* der, int derSz, const char* fileName);
48534853

48544854
#define DTLS_CID_BUFFER_SIZE 256
48554855

4856+
static WC_MAYBE_UNUSED void *mymemmem(const void *haystack, size_t haystacklen,
4857+
const void *needle, size_t needlelen)
4858+
{
4859+
size_t i, j;
4860+
const char* h = (const char*)haystack;
4861+
const char* n = (const char*)needle;
4862+
if (needlelen > haystacklen)
4863+
return NULL;
4864+
for (i = 0; i <= haystacklen - needlelen; i++) {
4865+
for (j = 0; j < needlelen; j++) {
4866+
if (h[i + j] != n[j])
4867+
break;
4868+
}
4869+
if (j == needlelen)
4870+
return (void*)(h + i);
4871+
}
4872+
return NULL;
4873+
}
4874+
48564875
#endif /* wolfSSL_TEST_H */

wolfssl/wolfcrypt/types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ typedef struct w64wrapper {
730730
#define XMEMSET(b,c,l) memset((b),(c),(l))
731731
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
732732
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
733-
#define XMEMMEM(h,hl,n,nl) mymemmem((h),(hl),(n),(nl))
734733

735734
#define XSTRLEN(s1) strlen((s1))
736735
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))

wolfssl/wolfcrypt/wc_port.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,6 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
12141214
#ifndef WOLFSSL_LEANPSK
12151215
char* mystrnstr(const char* s1, const char* s2, unsigned int n);
12161216
#endif
1217-
WOLFSSL_API void *mymemmem(const void *haystack, size_t haystacklen,
1218-
const void *needle, size_t needlelen);
12191217

12201218
#ifndef FILE_BUFFER_SIZE
12211219
/* default static file buffer size for input, will use dynamic buffer if

0 commit comments

Comments
 (0)