[Libvir] PATCH: Fix stats overflow
Daniel P. Berrange
berrange at redhat.com
Sat Nov 17 11:55:49 UTC 2007
FYI, I have just applied the attached patch to fix a 32-bit overflow in
the stats code. We were doing a left shift of more than 32 bits on '1L'
which is only 32-bit wide on 32-bit platforms. I simply cast to a long long
instead.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------- next part --------------
Index: stats_linux.c
===================================================================
RCS file: /data/cvs/libvirt/src/stats_linux.c,v
retrieving revision 1.3
diff -u -p -r1.3 stats_linux.c
--- stats_linux.c 15 Nov 2007 17:45:44 -0000 1.3
+++ stats_linux.c 17 Nov 2007 11:52:32 -0000
@@ -200,7 +200,7 @@ read_bd_stats (virConnectPtr conn, xenUn
* an assumed sector size.
*/
if (stats->rd_bytes > 0) {
- if (stats->rd_bytes >= 1L<<(63-9)) {
+ if (stats->rd_bytes >= ((unsigned long long)1)<<(63-9)) {
statsErrorFunc (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"stats->rd_bytes would overflow 64 bit counter",
domid);
@@ -209,7 +209,7 @@ read_bd_stats (virConnectPtr conn, xenUn
stats->rd_bytes *= 512;
}
if (stats->wr_bytes > 0) {
- if (stats->wr_bytes >= 1L<<(63-9)) {
+ if (stats->wr_bytes >= ((unsigned long long)1)<<(63-9)) {
statsErrorFunc (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"stats->wr_bytes would overflow 64 bit counter",
domid);
More information about the libvir-list
mailing list