Added checks on response size

Modified the reading of the response so that it cannot read more than the destination buffer size.