← Back to context

Comment by chasil

4 years ago

This appears to demonstrate the full range of abuse.

    $ mkdir hold
    $ cd hold

    $ cat ../wildname.c 
    #include <stdio.h>
    int main(int argc, char **argv)
    { char n[256]; int i,j=0; FILE *fp;

      for(i=1; i<256; i++) if(i!=47) n[j++] = i; n[j] = 0;
      if(fp = fopen(n, "w")) { fprintf(fp, "hello world!"); fclose(fp); }
    }

    $ cc ../wildname.c 
    $ ./a.out

    $ ls -l
    total 16
    -rw-r--r--. 1 luser lgroup   12 Nov 11 16:32 ??????????????????????????????? !"#$%&'()*+,-.0123456789:;<=>? 
 
 
 @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

    -rwxr-xr-x. 1 luser lgroup 8464 Nov 11 16:32 a.out

Just because you can do something does not mean that you should.

It's software. Software's contract is the same as a legal contract. And a legal contract mostly says what you can't do.

So anything not directly blocked by the software is allowed.

Ergo, clear specifications, strict yet flexible types and APIs, etc.

Otherwise, it's just bad design.