Date: Mon, 18 Feb 2008 22:26:42 -0500 From: Lowell Gilbert <freebsd-bugs-local@be-well.ilk.org> To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no> 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) Message-ID: <44k5l1mxsd.fsf@Lowell-Desk.lan> References: <47B90868.7000900@electron-tube.net> <86odae5rgr.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smørgrav <des@des.no> writes:
> Jim Bryant <freebsd@electron-tube.net> writes:
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> int main(int argc, char **argv) { int i; char buf[1024]; bzero(buf, 1024); for(i = 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=/dev/zero of=/dev/ad0s1 count=100", 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.
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 <unistd.h>
> #define b(i,v) for(int v=48;v<127;++v){f[i]=v;
> #define a(i) b(i,v##i)
> int main(void){char f[5]={'/'};a(1)a(2)a(3)truncate(f,0);}}}}
Entertaining, but not enough so to win the Obfuscated C contest.
I'm a pretty dedicated C user, but on this subject I've been using
shell scripts for testing.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44k5l1mxsd.fsf>
