MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / origin_matches_host

Function origin_matches_host

src/ui/http_server.c:106–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static bool origin_matches_host(const char *origin, const char *host, int port) {
107 /* Two literal loopback forms only — spelled out so the static URL audit
108 * sees the complete URL each branch can produce. */
109 char expected[128];
110 int length = strncmp(host, "localhost", 9) == 0
111 ? snprintf(expected, sizeof(expected), "http://localhost:%d", port)
112 : snprintf(expected, sizeof(expected), "http://127.0.0.1:%d", port);
113 return length > 0 && (size_t)length < sizeof(expected) && strcmp(origin, expected) == 0;
114}
115
116/* Foreign origins are rejected before this runs. Reflect only the exact
117 * same-server origin; a different localhost port is a different principal. */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected