linux: Fix false error condition with back-to-back packets

Correct "no progress" check in `esp_read_responses` to avoid issues with
back-to-back packets crashing the tunnel.
This commit is contained in:
Wladimir J. van der Laan 2020-02-23 12:45:56 +00:00
parent d1981173f7
commit 6a5f43b411

View File

@ -371,16 +371,17 @@ static bool esp_read_responses(int fd, bool early_terminate)
/* On non-final response, keep reading. */
} else {
if (esp_end == ESP_BUFSIZE) {
/* Buffer full but command wasn't complete - this isn't good,
* exit to prevent looping forever. */
my_err("Buffer full with unterminated command");
}
break;
}
ptr += len;
}
if (ptr == 0 && esp_end == ESP_BUFSIZE) {
/* Buffer full there was no progress processing responses - this isn't good,
* exit to prevent looping forever. */
my_err("Buffer full with unterminated command");
}
/* Remove processed responses from esp_buffer by shifting bytes. */
memmove(esp_buffer, &esp_buffer[ptr], esp_end - ptr);
esp_end -= ptr;