From owner-freebsd-fs@FreeBSD.ORG Tue Feb 19 03:41:49 2008 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C03216A418 for ; Tue, 19 Feb 2008 03:41:49 +0000 (UTC) (envelope-from Lowell@Be-Well.Ilk.Org) Received: from be-well.ilk.org (dsl092-078-145.bos1.dsl.speakeasy.net [66.92.78.145]) by mx1.freebsd.org (Postfix) with ESMTP id 6433613C442 for ; Tue, 19 Feb 2008 03:41:49 +0000 (UTC) (envelope-from Lowell@Be-Well.Ilk.Org) Received: from Lowell-Desk.lan (Lowell-Desk.lan [172.30.250.6]) by be-well.ilk.org (Postfix) with ESMTP id 71EB528472; Mon, 18 Feb 2008 22:26:43 -0500 (EST) Received: by Lowell-Desk.lan (Postfix, from userid 1147) id 5BD721CC72; Mon, 18 Feb 2008 22:26:42 -0500 (EST) To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= References: <47B90868.7000900@electron-tube.net> <86odae5rgr.fsf@ds4.des.no> From: Lowell Gilbert Date: Mon, 18 Feb 2008 22:26:42 -0500 Message-ID: <44k5l1mxsd.fsf@Lowell-Desk.lan> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-fs@freebsd.org Subject: Re: How to take down a system to the point of requiring a newfs with one line of C (userland) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2008 03:41:49 -0000 Dag-Erling Sm=F8rgrav writes: > Jim Bryant writes: >> #include >> #include >> >> int main(int argc, char **argv) { int i; char buf[1024]; bzero(buf, 1024= ); for(i =3D 0; i < 10000; i++) { sprintf(buf, "touch %s%05d\n", argv[1], i= ); system((const char *)buf);} return(0);} > > Subject should be "how to take down a system [...] with three lines of > badly written C, provided you have root privileges already and are too > lazy to just dd if=3D/dev/zero of=3D/dev/ad0s1 count=3D100", which would > accomplish the job much faster. I don't really see that argument, given that I can't understand *why* this code would produce the specific symptoms described in the original message.=20=20 For the record, I've been unable to reproduce the problem, so I'm unwilling to get too excited about it. > Purely in the interest of showing off, here is my version. It is 81 > bytes shorter than yours, it is valid C99 with POSIX extensions (yours > is not), and it produces 11,450 files in about 0.2% of the time yours > takes to produce 10,000. > > #include > #define b(i,v) for(int v=3D48;v<127;++v){f[i]=3Dv; > #define a(i) b(i,v##i) > int main(void){char f[5]=3D{'/'};a(1)a(2)a(3)truncate(f,0);}}}} Entertaining, but not enough so to win the Obfuscated C contest.=20=20 I'm a pretty dedicated C user, but on this subject I've been using shell scripts for testing.