mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-23 04:14:18 +01:00
@@ -60,21 +60,28 @@ check_host_origin(struct lws *wsi) {
|
||||
char buf[origin_length + 1];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
int len = lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_ORIGIN);
|
||||
if (len > 0) {
|
||||
if (len <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *prot, *address, *path;
|
||||
int port;
|
||||
if (lws_parse_uri(buf, &prot, &address, &port, &path))
|
||||
return false;
|
||||
if (port == 80 || port == 443) {
|
||||
sprintf(buf, "%s", address);
|
||||
} else {
|
||||
sprintf(buf, "%s:%d", address, port);
|
||||
}
|
||||
|
||||
int host_length = lws_hdr_total_length(wsi, WSI_TOKEN_HOST);
|
||||
if (host_length != strlen(buf))
|
||||
return false;
|
||||
char host_buf[host_length + 1];
|
||||
memset(host_buf, 0, sizeof(host_buf));
|
||||
len = lws_hdr_copy(wsi, host_buf, sizeof(host_buf), WSI_TOKEN_HOST);
|
||||
|
||||
return len > 0 && strcasecmp(buf, host_buf) == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -270,7 +270,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
strncpy(iface, optarg, sizeof(iface));
|
||||
strncpy(iface, optarg, sizeof(iface) - 1);
|
||||
iface[sizeof(iface) - 1] = '\0';
|
||||
break;
|
||||
case 'c':
|
||||
|
||||
Reference in New Issue
Block a user