[sf-lug] Obfuscating C code: 2[a] is the same as a[2]

Asheesh Laroia asheesh at asheesh.org
Sun Sep 7 17:53:01 PDT 2008

At lunch, after the SF-LUG meeting today, I made some crazy claims that, 
given an integer array a = {1,2,3}:

 	a[2] = 0;

is the same thing as

 	2[a] = 0;

My friend Venkatesh (CC:d for fun) write a good explanation of David 
Korn's entry for the International Obfuscated C Coding Contest at 
http://endeavour.zapto.org/notebook/compute/korn1987.html that explains 
why this:

 	main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}

prints the word "unix".  It's based on the same principle.  Plus a lot 


-- Asheesh.

P.S. This fortune as my signature was random but topical.

As of next Tuesday, C will be flushed in favor of COBOL.
Please update your programs.

More information about the sf-lug mailing list