server: don't get stuck in read() if TERM length is 0

This commit is contained in:
Daniel Eklöf 2019-11-02 12:17:30 +01:00
parent a1ba4cb010
commit 338747dc5a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -113,8 +113,10 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
term_env = malloc(term_env_len + 1);
term_env[term_env_len] = '\0';
if (recv(fd, term_env, term_env_len, 0) != term_env_len)
goto shutdown;
if (term_env_len > 0) {
if (recv(fd, term_env, term_env_len, 0) != term_env_len)
goto shutdown;
}
if (recv(fd, &client->argc, sizeof(client->argc), 0) != sizeof(client->argc))
goto shutdown;