X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fproxy.c;h=22d494718d959971e153f805b119e86ae1a71e6a;hp=165d3f34aa50dce224ff54631a178ff6569ee450;hb=57bbc06733b973fb0ed8ba226f9159de870768b2;hpb=776dbf88df1911ec379c2fece0089fd2f5c71021 diff --git a/src/proxy.c b/src/proxy.c index 165d3f34..22d49471 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -203,7 +203,7 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { case PROXY_SOCKS5: if(c->buflen < 2) return 0; - if(c->buffer[0] != 0x05 || c->buffer[1] == 0xff) { + if(c->buffer[0] != 0x05 || c->buffer[1] == (char)0xff) { logger(LOG_ERR, "Proxy authentication method rejected"); return -1; } @@ -256,7 +256,12 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { char *p = memchr(c->buffer, '\n', c->buflen); if(!p || p - c->buffer >= c->buflen) return 0; - p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer)); + + while((p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer)))) { + if(p > c->buffer + 3 && !memcmp(p - 3, "\r\n\r\n", 4)) + break; + } + if(!p) return 0;