--split-at-host: cancel if host not found

This commit is contained in:
ruti 2024-02-19 22:01:25 +03:00
parent 90d2a3e4f3
commit c59297b50b
2 changed files with 9 additions and 3 deletions

View File

@ -171,7 +171,7 @@ int desync(int sfd, char *buffer, size_t bfsize,
else if (type == IS_HTTPS && params.tlsrec) {
int o = params.tlsrec_pos;
if (params.tlsrec_sni) {
o += (host - buffer - 9 - 5);
o += (host - buffer - 5);
}
else if (o < 0) {
o += n;
@ -179,8 +179,11 @@ int desync(int sfd, char *buffer, size_t bfsize,
n = part_tls(buffer, bfsize, n, o);
}
if (host && params.split_host) {
pos += (host - buffer);
if (params.split_host) {
if (host)
pos += (host - buffer);
else
pos = 0;
}
else if (pos < 0) {
pos += n;

View File

@ -232,6 +232,9 @@ ssize_t part_tls(char *buffer, size_t bsize, ssize_t n, int pos)
return n;
}
uint16_t r_sz = ANTOHS(buffer, 3);
if (r_sz < pos) {
return n;
}
memmove(buffer + 5 + pos + 5, buffer + 5 + pos, n - (5 + pos));
memcpy(buffer + 5 + pos, buffer, 3);