
Signed-off-by: Christoph Hellwig <hch@lst.de>

diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index a980d20..4e97aa7 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -151,6 +151,12 @@ int get_obj_list(const struct sd_list_req *hdr, struct sd_list_rsp *rsp, void *d
 	}
 
 out:
+	if (hdr->data_length < obj_list_cache.cache_size * sizeof(uint64_t)) {
+		pthread_rwlock_unlock(&obj_list_cache.lock);
+		eprintf("GET_OBJ_LIST buffer too small\n");
+		return SD_RES_EIO;
+	}
+
 	rsp->data_length = obj_list_cache.cache_size * sizeof(uint64_t);
 	memcpy(data, obj_list_cache.buf, rsp->data_length);
 	pthread_rwlock_unlock(&obj_list_cache.lock);


