summaryrefslogtreecommitdiffstats
path: root/util/host-utils.c
diff options
context:
space:
mode:
authorLuis Pires2021-09-10 13:26:03 +0200
committerDavid Gibson2021-09-29 11:37:38 +0200
commit06c0259a086f0f4ddd57a14ba811bba0b9e45130 (patch)
tree35bd44452d7511b0f06fa3152ad67b35738a4216 /util/host-utils.c
parentMerge remote-tracking branch 'remotes/jsnow-gitlab/tags/python-pull-request' ... (diff)
downloadqemu-06c0259a086f0f4ddd57a14ba811bba0b9e45130.tar.gz
qemu-06c0259a086f0f4ddd57a14ba811bba0b9e45130.tar.xz
qemu-06c0259a086f0f4ddd57a14ba811bba0b9e45130.zip
host-utils: Fix overflow detection in divu128()
The previous code didn't detect overflows if the high 64-bit of the dividend were equal to the 64-bit divisor. In that case, 64 bits wouldn't be enough to hold the quotient. Signed-off-by: Luis Pires <luis.pires@eldorado.org.br> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210910112624.72748-2-luis.pires@eldorado.org.br> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'util/host-utils.c')
-rw-r--r--util/host-utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/host-utils.c b/util/host-utils.c
index 7b9322071d..a789a11b46 100644
--- a/util/host-utils.c
+++ b/util/host-utils.c
@@ -102,7 +102,7 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor)
*plow = dlo / divisor;
*phigh = dlo % divisor;
return 0;
- } else if (dhi > divisor) {
+ } else if (dhi >= divisor) {
return 1;
} else {