From a2be4feb021023408f19829b56219a21da2a2e07 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 12 Mar 2024 16:19:09 -0400 Subject: Changed strnstr to strnstr_local because mac apparently has this function defined by default. --- src/lpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lpm.c b/src/lpm.c index 16619c5..74c6a6a 100644 --- a/src/lpm.c +++ b/src/lpm.c @@ -1014,7 +1014,7 @@ static int strncicmp(const char* a, const char* b, int n) { return 0; } -static const char* strnstr(const char* haystack, const char* needle, int n) { +static const char* strnstr_local(const char* haystack, const char* needle, int n) { int len = strlen(needle); for (int i = 0; i <= n - len; ++i) { if (strncmp(&haystack[i], needle, len) == 0) @@ -1174,7 +1174,7 @@ static int lpm_get(lua_State* L) { while (1) { // If we have an unknown amount of chunk bytes to be fetched, determine the size of the next chunk. while (chunk_length == -1) { - char* newline = (char*)strnstr(buffer, "\r\n", buffer_length); + char* newline = (char*)strnstr_local(buffer, "\r\n", buffer_length); if (newline) { *newline = '\0'; if (sscanf(buffer, "%x", &chunk_length) != 1) { @@ -1226,7 +1226,7 @@ static int lpm_get(lua_State* L) { goto finish; } if (buffer_length >= 2) { - if (!strnstr(buffer, "\r\n", 2)) { + if (!strnstr_local(buffer, "\r\n", 2)) { snprintf(err, sizeof(err), "invalid end to chunk for %s%s", hostname, rest); goto cleanup; } -- cgit v1.2.3