server: verify CWD string length matches the indicated length

This commit is contained in:
Daniel Eklöf 2019-12-21 20:05:14 +01:00
parent cd382a467c
commit c91ef4c512
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -181,6 +181,12 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
const char *cwd = (const char *)p; p += cwd_len;
LOG_DBG("CWD = %.*s", cwd_len, cwd);
if (cwd_len != strlen(cwd) + 1) {
LOG_ERR("CWD length mismatch: indicated = %hu, actual = %zu",
cwd_len - 1, strlen(cwd));
goto shutdown;
}
CHECK_BUF(sizeof(uint16_t));
uint16_t term_env_len = *(uint16_t *)p; p += sizeof(term_env_len);