From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Mar 3 13:30:01 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A4A11065675 for ; Mon, 3 Mar 2008 13:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 560F28FC34 for ; Mon, 3 Mar 2008 13:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m23DU1rA037977 for ; Mon, 3 Mar 2008 13:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m23DU1ZL037976; Mon, 3 Mar 2008 13:30:01 GMT (envelope-from gnats) Resent-Date: Mon, 3 Mar 2008 13:30:01 GMT Resent-Message-Id: <200803031330.m23DU1ZL037976@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, MQ Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2A4C106566B for ; Mon, 3 Mar 2008 13:28:11 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id BFEA78FC13 for ; Mon, 3 Mar 2008 13:28:11 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m23DPE2N080818 for ; Mon, 3 Mar 2008 13:25:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m23DPEjM080817; Mon, 3 Mar 2008 13:25:14 GMT (envelope-from nobody) Message-Id: <200803031325.m23DPEjM080817@www.freebsd.org> Date: Mon, 3 Mar 2008 13:25:14 GMT From: MQ To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/121316: [patch]sysutils/xfce4-systemload-plugin integer multiplication overflow X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Mar 2008 13:30:01 -0000 >Number: 121316 >Category: ports >Synopsis: [patch]sysutils/xfce4-systemload-plugin integer multiplication overflow >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 03 13:30:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: MQ >Release: FreeBSD 7.0-RELEASE >Organization: >Environment: FreeBSD q6600.macro 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 10:35:36 UTC 2008 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: I've found an integer multiplication overflow in panel-plugin/memswap.c. When large memory is used, this bug will be triggered, causing the output of this plugin useless. >How-To-Repeat: Follow these steps when you have more than 3G memory (more than 2G must be enough to exploit this bug, but I have only tried installing 3G memory.) 1. cd /usr/ports/sysutils/xfce4-systemload-plugin && make install 2. Configure xfce4 to enable this plugin. 3. You will see that the output of the memory consumption is absolutely incorrect. >Fix: See my patch. Patch attached with submission follows: --- panel-plugin/memswap.c.orig 2007-01-18 02:01:09.000000000 +0800 +++ panel-plugin/memswap.c 2008-03-03 21:01:50.000000000 +0800 @@ -203,7 +203,7 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST, gulong *SU) { int total_pages; - int free_pages; + u_int free_pages; int inactive_pages; int pagesize = getpagesize(); int swap_avail; @@ -222,8 +222,8 @@ 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: