[dwatson cs ucr edu: [Fwd: [patch]: overflow bug in gtop]]


can someone please have a short look at this and commit the patch ?


----- Forwarded message from David Emory Watson <dwatson cs ucr edu> -----

X-From_: martin widget gnome org  Thu Sep 27 13:49:15 2001
Delivered-To: 5094 martin mail ahnet net
Delivered-To: martin widget gnome org
Delivered-To: martin gnome org
Date: Thu, 27 Sep 2001 13:53:10 -0700
From: David Emory Watson <dwatson cs ucr edu>
Subject: [Fwd: [patch]: overflow bug in gtop]
To: martin gnome org
X-Mailer: Evolution/0.14 (Preview Release)

Hope this is the correct place to send this... :)

Content-Description: Forwarded message - [patch]: overflow bug in gtop
Subject: [patch]: overflow bug in gtop
From: David Emory Watson <dwatson cs ucr edu>
To: baulig suse de
X-Mailer: Evolution/0.14 (Preview Release)
Date: 27 Sep 2001 13:43:46 -0700


I have found a bug in gtop-1.0.13.  The attached patch should fix the
problem.  The variable named value was overflowing so I made it the same
size as d->value_total.  I also moved the shift out of the loop to save
a few instructions (in terms of functionality, this is unnecessary).

- David

--- ./gtop-1.0.13/fsusage.c	Tue Feb 27 06:41:28 2001
+++ ./gtop-1.0.13-overflow/fsusage.c	Thu Sep 27 13:35:19 2001
@@ -277,7 +277,7 @@ fsusage_update (GTopFsUsageData *d)
 	FsUsageProcInfo *ti;
 	gint n = 0, i, j, k = 0;
-	unsigned long value, percent;
+	gint64 value, percent;
 	glibtop_mountlist mountlist;
 	GTopPropFsMode fsmode;
 	glong selected_fs_mask;
@@ -389,9 +389,12 @@ fsusage_update (GTopFsUsageData *d)
 		ti [k].cmd       = g_strdup (mount_list [i].mountdir);
 		ti [k].percent   = percent;
 		ti [k].value     = value;
-		d->value_total  += value << 10;
+		d->value_total  += value;
+	/* translate into bytes. */
+	d->value_total <<= 10;
 	n = k;

----- End forwarded message -----

Martin Baulig
martin gnome org (private)
baulig suse de (work)

gnome-hackers mailing list
gnome-hackers gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]