knc: fix a couple of memory leaks.

One of these can be remotely triggered during the authentication
phase which leads to a remote DoS possibility.

Pointed out by: Imre Rad <radimre83@gmail.com>
timed_read(int fd, void *buf, size_t bytes, int timeout)
{
	struct pollfd		fds[1];
	int			ret;

	if (timeout > 0) {
		fds[0].fd = fd;
		fds[0].events = POLLIN;

		ret = poll(fds, 1, timeout);

		if (ret == -1)
			return -1;

		if (ret != 1) {
			errno = ETIMEDOUT;
			return -1;
		}
	}

	return read(fd, buf, bytes);
}

timed_read(int fd, void *buf, size_t bytes, int timeout)
{
	struct pollfd		fds[1];
	int			ret;

	if (timeout > 0) {
		fds[0].fd = fd;
		fds[0].events = POLLIN;

		ret = poll(fds, 1, timeout);

		if (ret == -1)
			return -1;

		if (ret != 1) {
			errno = ETIMEDOUT;
			return -1;
		}
	}

	return read(fd, buf, bytes);
}
