Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Mar 2011 22:19:18 GMT
From:      Zhihao Yuan <lichray@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/155382: sysutils/xfce4-systemload-plugin: Memory size overflow when >3.5GB
Message-ID:  <201103082219.p28MJIrX090151@red.freebsd.org>
Resent-Message-ID: <201103082220.p28MK8CB049508@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         155382
>Category:       ports
>Synopsis:       sysutils/xfce4-systemload-plugin: Memory size overflow when >3.5GB
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 08 22:20:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Zhihao Yuan
>Release:        FreeBSD 8.2-STABLE
>Organization:
Northern Illinois University
>Environment:
FreeBSD compaq.yuetime 8.2-STABLE FreeBSD 8.2-STABLE #0: Tue Mar  8 01:53:40 CST 2011     root@compaq.yuetime:/usr/obj/usr/src/sys/HOUKAGO  amd64
>Description:
In file panel-plugin/memswap.c , the author defined the *_pages
variables as int, which is long enough to represent the length of pages.
But he multiplied the total_pages by pagesize, so the overflow occurred.
>How-To-Repeat:
Starts xfce4-systemload-plugin on a system with more than 3.5GB real
memory, you will see a very huge number for the total memory (If the
used memory is larger than 3.5GB, no lucky).
>Fix:
Use the authors' own macro CONVERT(_pages), which casts the page length
into quad_t, to calculate the memory sizes.


Patch attached with submission follows:

--- panel-plugin/memswap.c.orig	2010-12-09 10:04:10.000000000 -0600
+++ panel-plugin/memswap.c	2011-02-22 21:41:38.000000000 -0600
@@ -228,8 +228,8 @@ gint read_memswap(gulong *mem, gulong *s
         return -1;
     }
 
-    *MT = (total_pages*pagesize) >> 10;
-    *MU = ((total_pages-free_pages-inactive_pages) * pagesize) >> 10;
+    *MT = CONVERT(total_pages);
+    *MU = CONVERT(total_pages-free_pages-inactive_pages);
     *mem = *MU * 100 / *MT;
 
     if((*swap = swapmode(&swap_avail, &swap_free)) >= 0) {


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103082219.p28MJIrX090151>