C obfuscator (Obfuscator code attached)
Geoff Clare
gwc at root.co.uk
Fri Jun 1 00:23:12 AEST 1990
In <19858 at duke.cs.duke.edu> drh at romeo.cs.duke.edu (D. Richard Hipp) writes:
>The program below reads a C program from standard input, strips away all
>unnecessary white space and writes the results to standard output. The
>result is a program which has been obfuscated.
BEWARE!! Removing white space can alter C code!!
In fact, this is what happened when I compiled Richard's program:
line 22: warning: ambiguous assignment: assignment op taken
line 22: warning: old-fashioned assignment operator
line 22: operands of *= have incompatible types
line 22: warning: old-fashioned assignment operator
line 22: operands of *= have incompatible types
....
line 34: warning: ambiguous assignment: assignment op taken
line 34: warning: old-fashioned assignment operator
line 34: operands of *= have incompatible types
This wouldn't happen with most modern compilers, but serves to demonstrate
the problem. After inserting a space in all the '=*'s, the program seemed
to run OK, but how do I know it's running correctly? Subtle alterations
which may never be noticed are possible, e.g. the expression
x = y + ++z;
after processing becomes:
x=y+++z;
which actually parses as:
x = y++ + z;
This silently changes the behaviour of the code, such that it produces
incorrect results and the user is none the wiser.
You have been warned!
--
Geoff Clare, UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH
gwc at root.co.uk (Dumb mailers: ...!uunet!root.co.uk!gwc) Tel: +44-71-315-6600
More information about the Comp.lang.c
mailing list