Check read length before memcmp()