mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
migration/multifd: Fix loop conditions in multifd_zstd_send_prepare and multifd_zstd_recv
GitHub's CodeQL reports four critical errors which are fixed by this commit: Unsigned difference expression compared to zero An expression (u - v > 0) with unsigned values u, v is only false if u == v, so all changed expressions did not work as expected. Signed-off-by: Stefan Weil <sw@weilnetz.de> Link: https://lore.kernel.org/r/20240910054138.1458555-1-sw@weilnetz.de [peterx: Fix mangled email for author] Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
561ce01493
commit
cb0ed522a5
1 changed files with 4 additions and 4 deletions
|
@ -123,9 +123,9 @@ static int multifd_zstd_send_prepare(MultiFDSendParams *p, Error **errp)
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ret = ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush);
|
ret = ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush);
|
||||||
} while (ret > 0 && (z->in.size - z->in.pos > 0)
|
} while (ret > 0 && (z->in.size > z->in.pos)
|
||||||
&& (z->out.size - z->out.pos > 0));
|
&& (z->out.size > z->out.pos));
|
||||||
if (ret > 0 && (z->in.size - z->in.pos > 0)) {
|
if (ret > 0 && (z->in.size > z->in.pos)) {
|
||||||
error_setg(errp, "multifd %u: compressStream buffer too small",
|
error_setg(errp, "multifd %u: compressStream buffer too small",
|
||||||
p->id);
|
p->id);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -243,7 +243,7 @@ static int multifd_zstd_recv(MultiFDRecvParams *p, Error **errp)
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
|
ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
|
||||||
} while (ret > 0 && (z->in.size - z->in.pos > 0)
|
} while (ret > 0 && (z->in.size > z->in.pos)
|
||||||
&& (z->out.pos < page_size));
|
&& (z->out.pos < page_size));
|
||||||
if (ret > 0 && (z->out.pos < page_size)) {
|
if (ret > 0 && (z->out.pos < page_size)) {
|
||||||
error_setg(errp, "multifd %u: decompressStream buffer too small",
|
error_setg(errp, "multifd %u: decompressStream buffer too small",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue