| 104 | } |
| 105 | |
| 106 | static 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. */ |
no outgoing calls
no test coverage detected