Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Oct 2001 16:28:05 -0700
From:      mki <mki@mozone.net>
To:        freebsd-hackers@FreeBSD.org
Subject:   4.4-stable, savecore and integer overflow in get_dumpsize()
Message-ID:  <20011004162805.C1671@cyclonus.mozone.net>

next in thread | raw e-mail | index | archive | help
It appears that get_dumpsize is b0rked in that the following
returns a negative number for systems with large memory/swap 
configs:

void
get_dumpsize()
{
        int kdumpsize;

        /* Read the dump size. */
        DumpRead(dumpfd, &kdumpsize, sizeof(kdumpsize),
            (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), L_SET);
        dumpsize = kdumpsize * getpagesize();
}


the dumpsize = kdumpsize * getpagesize() produces a negative
number when kdumpsize = 1032192; resulting in savecore exiting without
actually performing the dump in save_core().

Here's the patch to address it:

--- savecore.c.old	Thu Oct  4 16:22:16 2001
+++ savecore.c	Thu Oct  4 16:25:07 2001
@@ -601,7 +601,7 @@
 	/* Read the dump size. */
 	DumpRead(dumpfd, &kdumpsize, sizeof(kdumpsize),
 	    (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), L_SET);
-	dumpsize = kdumpsize * getpagesize();
+	dumpsize = (off_t) kdumpsize * (off_t) getpagesize();
 }
 
 /*

can someone please commit this fix?  

thanks
-mohan


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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