提交 91f827dc 编写于 作者: M Max Reitz 提交者: Kevin Wolf

qcow2: Avoid overflow in alloc_clusters_noref()

alloc_clusters_noref() stores the cluster index in a uint64_t. However,
offsets are often represented as int64_t (as for example the return
value of alloc_clusters_noref() itself demonstrates). Therefore, we
should make sure all offsets in the allocated range of clusters are
representable using int64_t without overflows.
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 35d0d40a
......@@ -653,6 +653,13 @@ retry:
goto retry;
}
}
/* Make sure that all offsets in the "allocated" range are representable
* in an int64_t */
if (s->free_cluster_index - 1 > (INT64_MAX >> s->cluster_bits)) {
return -EFBIG;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n",
size,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册