On Wed 05 Aug 2020 11:22:58 AM CEST, Tuguoyi wrote: > This patch fix it by casting @i to uint64_t before doing left shift > operation
The patch seems fine and I also think that it's perhaps worth a test case (although it only seems to happen with preallocation=falloc or full so the test would need to generate very large files). But I also wonder if there are other cases where this can happen. nb_clusters is an int and there are more cases of nb_clusters << s->cluster_bits I can see at least these: handle_alloc(), qcow2_free_any_clusters(), qcow2_alloc_cluster_abort(). Berto