Skip to content

How to properly compile it? #6

@HeavyTony2

Description

@HeavyTony2

So, on Colab, I run !make and here's the result

!make
cc    -c -o worm.o worm.c
In file included from worm.c:3:
worm.h:43:8: warning: type defaults to ‘int’ in declaration of ‘nifs’ [-Wimplicit-int]
   43 | extern nifs;
      |        ^~~~
worm.c:18:8: warning: type defaults to ‘int’ in declaration of ‘errno’ [-Wimplicit-int]
   18 | extern errno;
      |        ^~~~~
worm.c:19:14: warning: conflicting types for built-in function ‘malloc’; expected ‘void *(long unsigned int)’ [-Wbuiltin-declaration-mismatch]
   19 | extern char *malloc();
      |              ^~~~~~
worm.c:17:1: note: ‘malloc’ is declared in header ‘<stdlib.h>’
   16 | #include <arpa/inet.h>
  +++ |+#include <stdlib.h>
   17 | 
worm.c:32:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   32 | main(argc, argv)                /* 0x20a0 */
      | ^~~~
worm.c: In function ‘main’:
worm.c:42:5: warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration]
   42 |     strcpy(argv[0], XS("sh"));                  /* <env+52> */
      |     ^~~~~~
worm.c:17:1: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
   16 | #include <arpa/inet.h>
  +++ |+#include <string.h>
   17 | 
worm.c:42:5: warning: incompatible implicit declaration of built-in function ‘strcpy’ [-Wbuiltin-declaration-mismatch]
   42 |     strcpy(argv[0], XS("sh"));                  /* <env+52> */
      |     ^~~~~~
worm.c:42:5: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
worm.c:43:5: warning: implicit declaration of function ‘time’; did you mean ‘utimes’? [-Wimplicit-function-declaration]
   43 |     time(&key);
      |     ^~~~
      |     utimes
worm.c:44:5: warning: implicit declaration of function ‘srandom’ [-Wimplicit-function-declaration]
   44 |     srandom(key);
      |     ^~~~~~~
worm.c:53:10: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
   53 |          strcmp(argv[cur_arg], XS("-p")) == 0) { /* env55 == "-p" */
      |          ^~~~~~
worm.c:53:10: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
worm.c:54:19: warning: implicit declaration of function ‘atoi’ [-Wimplicit-function-declaration]
   54 |         pid_arg = atoi(argv[2]);
      |                   ^~~~
worm.c:58:13: warning: implicit declaration of function ‘loadobject’ [-Wimplicit-function-declaration]
   58 |         if (loadobject(argv[i]) == 0)
      |             ^~~~~~~~~~
worm.c:59:13: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
   59 |             exit(1);
      |             ^~~~
worm.c:59:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c:59:13: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
worm.c:59:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c:61:13: warning: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration]
   61 |             unlink(argv[i]);
      |             ^~~~~~
worm.c:64:9: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
   64 |         exit(1);
      |         ^~~~
worm.c:64:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c:67:13: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
   67 |             close(i);
      |             ^~~~~
      |             pclose
worm.c:77:9: warning: implicit declaration of function ‘if_init’ [-Wimplicit-function-declaration]
   77 |     if (if_init() == 0)
      |         ^~~~~~~
worm.c:78:9: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
   78 |         exit(1);
      |         ^~~~
worm.c:78:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c:80:24: warning: implicit declaration of function ‘getpgrp’ [-Wimplicit-function-declaration]
   80 |         if (pid_arg == getpgrp(getpid()))
      |                        ^~~~~~~
worm.c:80:32: warning: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
   80 |         if (pid_arg == getpgrp(getpid()))
      |                                ^~~~~~
worm.c:81:13: warning: implicit declaration of function ‘setpgrp’ [-Wimplicit-function-declaration]
   81 |             setpgrp(getpid(), getpid());
      |             ^~~~~~~
worm.c:84:5: warning: implicit declaration of function ‘mainloop’ [-Wimplicit-function-declaration]
   84 |     mainloop();
      |     ^~~~~~~~
worm.c: At top level:
worm.c:87:8: warning: return type defaults to ‘int’ [-Wimplicit-int]
   87 | static mainloop()                               /* 0x2302 */
      |        ^~~~~~~~
worm.c:87:8: error: static declaration of ‘mainloop’ follows non-static declaration
worm.c:84:5: note: previous implicit declaration of ‘mainloop’ with type ‘int()’
   84 |     mainloop();
      |     ^~~~~~~~
worm.c: In function ‘mainloop’:
worm.c:94:9: warning: implicit declaration of function ‘hg’ [-Wimplicit-function-declaration]
   94 |     if (hg() == 0 && hl() == 0)
      |         ^~
worm.c:94:22: warning: implicit declaration of function ‘hl’ [-Wimplicit-function-declaration]
   94 |     if (hg() == 0 && hl() == 0)
      |                      ^~
worm.c:95:9: warning: implicit declaration of function ‘ha’ [-Wimplicit-function-declaration]
   95 |         ha();
      |         ^~
worm.c:96:5: warning: implicit declaration of function ‘checkother’ [-Wimplicit-function-declaration]
   96 |     checkother();
      |     ^~~~~~~~~~
worm.c:97:5: warning: implicit declaration of function ‘report_breakin’ [-Wimplicit-function-declaration]
   97 |     report_breakin();
      |     ^~~~~~~~~~~~~~
worm.c:98:5: warning: implicit declaration of function ‘cracksome’ [-Wimplicit-function-declaration]
   98 |     cracksome();
      |     ^~~~~~~~~
worm.c:99:5: warning: implicit declaration of function ‘other_sleep’ [-Wimplicit-function-declaration]
   99 |     other_sleep(30);
      |     ^~~~~~~~~~~
worm.c:104:13: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
  104 |         if (fork() > 0)
      |             ^~~~
worm.c:105:13: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  105 |             exit(0);
      |             ^~~~
worm.c:105:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c:106:26: warning: implicit declaration of function ‘hi’ [-Wimplicit-function-declaration]
  106 |         if (hg() == 0 && hi() == 0 && ha() == 0)
      |                          ^~
worm.c:111:13: warning: implicit declaration of function ‘h_clean’ [-Wimplicit-function-declaration]
  111 |             h_clean();
      |             ^~~~~~~
worm.c:113:13: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
  113 |             exit(0);
      |             ^~~~
worm.c:113:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
worm.c: At top level:
worm.c:117:8: warning: type defaults to ‘int’ in declaration of ‘trans_cnt’ [-Wimplicit-int]
  117 | static trans_cnt;
      |        ^~~~~~~~~
worm.c:143:8: warning: return type defaults to ‘int’ [-Wimplicit-int]
  143 | static report_breakin(arg1, arg2)               /* 0x2494 */
      |        ^~~~~~~~~~~~~~
worm.c:143:8: error: static declaration of ‘report_breakin’ follows non-static declaration
worm.c:97:5: note: previous implicit declaration of ‘report_breakin’ with type ‘int()’
   97 |     report_breakin();
      |     ^~~~~~~~~~~~~~
worm.c: In function ‘report_breakin’:
worm.c:143:8: warning: type of ‘arg1’ defaults to ‘int’ [-Wimplicit-int]
  143 | static report_breakin(arg1, arg2)               /* 0x2494 */
      |        ^~~~~~~~~~~~~~
worm.c:143:8: warning: type of ‘arg2’ defaults to ‘int’ [-Wimplicit-int]
worm.c:149:14: warning: implicit declaration of function ‘random’ [-Wimplicit-function-declaration]
  149 |     if (7 != random() % 15)
      |              ^~~~~~
worm.c:150:9: warning: ‘return’ with no value, in function returning non-void
  150 |         return;
      |         ^~~~~~
worm.c:143:8: note: declared here
  143 | static report_breakin(arg1, arg2)               /* 0x2494 */
      |        ^~~~~~~~~~~~~~
worm.c:160:9: warning: ‘return’ with no value, in function returning non-void
  160 |         return;
      |         ^~~~~~
worm.c:143:8: note: declared here
  143 | static report_breakin(arg1, arg2)               /* 0x2494 */
      |        ^~~~~~~~~~~~~~
worm.c:161:31: warning: passing argument 5 of ‘sendto’ from incompatible pointer type [-Wincompatible-pointer-types]
  161 |     if (sendto(s, &msg, 1, 0, &sin, sizeof(sin)))
      |                               ^~~~
      |                               |
      |                               struct sockaddr_in *
In file included from worm.c:11:
/usr/include/x86_64-linux-gnu/sys/socket.h:153:58: note: expected ‘const struct sockaddr *’ but argument is of type ‘struct sockaddr_in *’
  153 |                        int __flags, __CONST_SOCKADDR_ARG __addr,
      |                                                          ^
make: *** [<builtin>: worm.o] Error 1

This is basically the error code I've got each time I tried over the years.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions