Self-printing program (was Re: The Scope and Ownership of fedora-list)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2008-08-27 at 16:54 -0430, Patrick O'Callaghan wrote:
> On Wed, 2008-08-27 at 13:18 -0500, Mike Chambers wrote:
> > > p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
> > 
> > Not being a programmer or anything, WHAT in the heck IS that? LOL
> 
> It's C. There's a whole class of things like this. Google for
> "Obfuscated C Contest".
> 
> BTW it won't compile without a load of warnings. I can't be bothered
> working out how to turn them off.
> 
> poc

This is a short program of the type that Thompson described in
"Reflections on Trusting Trust"[0]. This version can be compiled with
gcc (with one warning):

        char* p="char* p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}

When run, it prints its own source code.

-Chris


[0] This is an amazing paper. It describes why you can't trust software
for which you have audited the source code and compiled your own binary.
Original PDF from the ACM site:
http://portal.acm.org/citation.cfm?id=358210 
or html format from Ken Thompson's site at Bell Labs:
http://cm.bell-labs.com/who/ken/trust.html

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux