@@ -60,21 +60,28 @@ check_host_origin(struct lws *wsi) {
6060 char buf [origin_length + 1 ];
6161 memset (buf , 0 , sizeof (buf ));
6262 int len = lws_hdr_copy (wsi , buf , sizeof (buf ), WSI_TOKEN_ORIGIN );
63- if (len > 0 ) {
64- const char * prot , * address , * path ;
65- int port ;
66- if (lws_parse_uri (buf , & prot , & address , & port , & path ))
67- return false;
63+ if (len <= 0 ) {
64+ return false;
65+ }
66+
67+ const char * prot , * address , * path ;
68+ int port ;
69+ if (lws_parse_uri (buf , & prot , & address , & port , & path ))
70+ return false;
71+ if (port == 80 || port == 443 ) {
72+ sprintf (buf , "%s" , address );
73+ } else {
6874 sprintf (buf , "%s:%d" , address , port );
69- int host_length = lws_hdr_total_length (wsi , WSI_TOKEN_HOST );
70- if (host_length != strlen (buf ))
71- return false;
72- char host_buf [host_length + 1 ];
73- memset (host_buf , 0 , sizeof (host_buf ));
74- len = lws_hdr_copy (wsi , host_buf , sizeof (host_buf ), WSI_TOKEN_HOST );
75- return len > 0 && strcasecmp (buf , host_buf ) == 0 ;
7675 }
77- return false;
76+
77+ int host_length = lws_hdr_total_length (wsi , WSI_TOKEN_HOST );
78+ if (host_length != strlen (buf ))
79+ return false;
80+ char host_buf [host_length + 1 ];
81+ memset (host_buf , 0 , sizeof (host_buf ));
82+ len = lws_hdr_copy (wsi , host_buf , sizeof (host_buf ), WSI_TOKEN_HOST );
83+
84+ return len > 0 && strcasecmp (buf , host_buf ) == 0 ;
7885}
7986
8087void
0 commit comments