Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#63124 closed defect (fixed)

cryptcat @1.2.1: error: implicit declaration of function 'close' is invalid in C99

Reported by: cooljeanius (Eric Gallager) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: bigsur catalina Cc:
Port: cryptcat

Description

Another victim of -Werror=implicit-function-declaration being on by default now:

cc -O   -c -o netcat.o netcat.c
netcat.c:41:26: warning: '/*' within block comment [-Wcomment]
/* #undef _POSIX_SOURCE         /* might need this for something? */
                                ^
netcat.c:44:19: warning: '/*' within block comment [-Wcomment]
/* #define ANAL                 /* if you want case-sensitive DNS matching */
                                ^
netcat.c:208:19: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        fprintf (stderr, h_errs[h_errno]);      /* handle it here */
                         ^~~~~~~~~~~~~~~
netcat.c:208:19: note: treat the string as an argument to avoid this
        fprintf (stderr, h_errs[h_errno]);      /* handle it here */
                         ^
                         "%s", 
netcat.c:228:3: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  close (netfd);
  ^
netcat.c:229:3: error: implicit declaration of function 'sleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sleep (1);
  ^
netcat.c:239:42: warning: too few arguments in call to 'bail'
    bail (wrote_txt, wrote_net, wrote_out);
    ~~~~                                 ^
netcat.c:239:22: warning: incompatible integer to pointer conversion passing 'unsigned int' to parameter of type 'char *' [-Wint-conversion]
    bail (wrote_txt, wrote_net, wrote_out);
                     ^~~~~~~~~
netcat.c:239:33: warning: incompatible integer to pointer conversion passing 'unsigned int' to parameter of type 'char *' [-Wint-conversion]
    bail (wrote_txt, wrote_net, wrote_out);
                                ^~~~~~~~~
netcat.c:240:17: warning: too few arguments in call to 'bail'
  bail (" punt!");
  ~~~~          ^
netcat.c:247:3: error: implicit declaration of function 'alarm' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  alarm (0);
  ^
netcat.c:249:38: warning: too few arguments in call to 'bail'
    bail ("spurious timer interrupt!");
    ~~~~                             ^
netcat.c:261:5: error: implicit declaration of function 'alarm' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    alarm (0);
    ^
netcat.c:265:5: error: implicit declaration of function 'alarm' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    alarm (secs);
    ^
netcat.c:281:33: warning: too few arguments in call to 'bail'
    bail ("Hmalloc %d failed", s);
    ~~~~                        ^
netcat.c:281:32: warning: incompatible integer to pointer conversion passing 'unsigned int' to parameter of type 'char *' [-Wint-conversion]
    bail ("Hmalloc %d failed", s);
                               ^
netcat.c:331:69: warning: too few arguments in call to 'holler'
    holler ("DNS fwd/rev mismatch: %s != %s", poop->name, hp->h_name);
    ~~~~~~                                                          ^
netcat.c:376:32: warning: too few arguments in call to 'bail'
    bail ("gethostpoop fuxored");
    ~~~~                       ^
netcat.c:383:52: warning: too few arguments in call to 'bail'
      bail ("Can't parse %s as an IP address", name);
      ~~~~                                         ^
netcat.c:387:53: warning: too few arguments in call to 'bail'
      bail ("%s: forward host lookup failed: ", name);
      ~~~~                                          ^
netcat.c:403:18: warning: too few arguments in call to 'holler'
          poop->addrs[x]);
                        ^
netcat.c:418:50: warning: too few arguments in call to 'holler'
        holler ("%s: inverse host lookup failed: ", name);
        ~~~~~~                                          ^
netcat.c:424:13: warning: too few arguments in call to 'holler'
                poop->name);
                          ^
netcat.c:410:5: warning: 'strncpy' will always overflow; destination buffer has size 24, but size argument is 192 [-Wbuiltin-memcpy-chk-size]
    strncpy (poop->addrs[0], inet_ntoa (iaddr), sizeof (poop->addrs));
    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/secure/_string.h:128:3: note: expanded from macro 'strncpy'
                __builtin___strncpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
netcat.c:469:56: warning: too few arguments in call to 'holler'
        holler ("Warning: port-bynum mismatch, %d != %d", x, y);
        ~~~~~~                                                ^
netcat.c:469:52: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
        holler ("Warning: port-bynum mismatch, %d != %d", x, y);
                                                          ^
netcat.c:469:55: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
        holler ("Warning: port-bynum mismatch, %d != %d", x, y);
                                                             ^
netcat.c:567:34: warning: too few arguments in call to 'bail'
    bail ("loadports: no block?!");
    ~~~~                         ^
netcat.c:569:51: warning: too few arguments in call to 'bail'
    bail ("loadports: bogus values %d, %d", lo, hi);
    ~~~~                                          ^
netcat.c:569:45: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
    bail ("loadports: bogus values %d, %d", lo, hi);
                                            ^~
netcat.c:569:49: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
    bail ("loadports: bogus values %d, %d", lo, hi);
                                                ^~
netcat.c:631:29: warning: too few arguments in call to 'bail'
    bail ("Can't get socket");
    ~~~~                    ^
netcat.c:637:38: warning: too few arguments in call to 'holler'
    holler ("nnetfd reuseaddr failed");         /* ??? */
    ~~~~~~                           ^
netcat.c:641:38: warning: too few arguments in call to 'holler'
    holler ("nnetfd reuseport failed");         /* ??? */
    ~~~~~~                           ^
netcat.c:675:66: warning: too few arguments in call to 'holler'
        holler ("retrying local %s:%d", inet_ntoa (lclend->sin_addr), lp);
        ~~~~~~                                                          ^
netcat.c:675:64: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
        holler ("retrying local %s:%d", inet_ntoa (lclend->sin_addr), lp);
                                                                      ^~
netcat.c:676:2: error: implicit declaration of function 'sleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        sleep (2);
        ^
netcat.c:683:33: warning: too few arguments in call to 'bail'
        inet_ntoa(lclend->sin_addr), lp);
                                       ^
netcat.c:683:31: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
        inet_ntoa(lclend->sin_addr), lp);
                                     ^~
netcat.c:754:39: warning: too few arguments in call to 'bail'
      bail ("srcrt setsockopt fuxored");
      ~~~~                            ^
netcat.c:771:3: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  close (nnetfd);                       /* clean up junked socket FD!! */
  ^
netcat.c:735:16: warning: implicit conversion from 'int' to 'char' changes value from 131 to -125 [-Wconstant-conversion]
      *opp++ = IPOPT_LSRR;                                      /* option */
             ~ ^~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/netinet/ip.h:172:33: note: expanded from macro 'IPOPT_LSRR'
#define IPOPT_LSRR              131             /* loose source route */
                                ^~~
netcat.c:800:38: warning: too few arguments in call to 'bail'
      bail ("UDP listen needs -p arg");
      ~~~~                           ^
netcat.c:804:35: warning: too few arguments in call to 'bail'
      bail ("local listen fuxored");
      ~~~~                        ^
netcat.c:818:46: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
    rr = getsockname (nnetfd, (SA *) lclend, &x);
                                             ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/socket.h:706:78: note: passing argument to parameter here
int     getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict)
                                                                             ^
netcat.c:820:41: warning: too few arguments in call to 'holler'
      holler ("local getsockname failed");
      ~~~~~~                            ^
netcat.c:828:26: warning: too few arguments in call to 'holler'
    holler (bigbuf_net, z);
    ~~~~~~               ^
netcat.c:828:25: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
    holler (bigbuf_net, z);
                        ^
netcat.c:841:56: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
        (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (SA *) remend, &x);
                                                              ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/socket.h:712:27: note: passing argument to parameter here
    socklen_t * __restrict) __DARWIN_ALIAS_C(recvfrom);
                          ^
netcat.c:865:40: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
    rr = accept (nnetfd, (SA *)remend, &x);
                                       ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/socket.h:700:73: note: passing argument to parameter here
int     accept(int, struct sockaddr * __restrict, socklen_t * __restrict)
                                                                        ^
netcat.c:869:3: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  close (nnetfd);               /* dump the old socket */
  ^
netcat.c:886:60: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
  rr = getsockopt (nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x);
                                                           ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/socket.h:708:76: note: passing argument to parameter here
int     getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
                                                                           ^
netcat.c:888:32: warning: too few arguments in call to 'holler'
    holler ("getsockopt failed");
    ~~~~~~                     ^
netcat.c:901:41: warning: too few arguments in call to 'holler'
    holler ("IP options: %s", bigbuf_net);
    ~~~~~~                              ^
netcat.c:913:44: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
  rr = getsockname (nnetfd, (SA *) lclend, &x);
                                           ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/socket.h:706:78: note: passing argument to parameter here
int     getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict)
                                                                             ^
netcat.c:915:42: warning: too few arguments in call to 'holler'
    holler ("post-rcv getsockname failed");
    ~~~~~~                               ^
netcat.c:940:39: warning: too few arguments in call to 'bail'
        cp, whozis->name, whozis->addrs[0], z);
                                             ^
netcat.c:940:38: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
        cp, whozis->name, whozis->addrs[0], z);
                                            ^
netcat.c:942:39: warning: too few arguments in call to 'holler'
        cp, whozis->name, whozis->addrs[0], z);
                                             ^
netcat.c:942:38: warning: incompatible integer to pointer conversion passing 'unsigned short' to parameter of type 'char *' [-Wint-conversion]
        cp, whozis->name, whozis->addrs[0], z);
                                            ^
netcat.c:962:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
udptest (fd, where)
^
netcat.c:968:8: error: implicit declaration of function 'write' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  rr = write (fd, bigbuf_in, 1);
       ^
netcat.c:968:8: note: did you mean 'fwrite'?
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/stdio.h:165:9: note: 'fwrite' declared here
size_t   fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
         ^
netcat.c:970:59: warning: too few arguments in call to 'holler'
    holler ("udptest first write failed?! errno %d", errno);
    ~~~~~~                                                ^
netcat.c:970:54: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
    holler ("udptest first write failed?! errno %d", errno);
                                                     ^~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/sys/errno.h:81:15: note: expanded from macro 'errno'
#define errno (*__error())
              ^~~~~~~~~~~~
netcat.c:972:5: error: implicit declaration of function 'sleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    sleep (o_wait);
    ^
netcat.c:983:7: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      close (rr);                       /* in case it *did* open */
      ^
netcat.c:991:3: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  close (fd);                           /* use it or lose it! */
  ^
netcat.c:1020:44: warning: too few arguments in call to 'bail'
    bail ("oprint called with no open fd?!");
    ~~~~                                   ^
netcat.c:1057:14: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    sprintf (&stage[2], "%8.8x ", obc);         /* xxx: still slow? */
             ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/secure/_stdio.h:47:28: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                           ^~~
netcat.c:1080:9: error: implicit declaration of function 'write' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    x = write (ofd, stage, soc);
        ^
netcat.c:1082:28: warning: too few arguments in call to 'bail'
      bail ("ofd write err");
      ~~~~                 ^
netcat.c:1147:43: warning: too few arguments in call to 'holler'
    holler ("Preposterous fd value %d", fd);
    ~~~~~~                                ^
netcat.c:1147:41: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'char *' [-Wint-conversion]
    holler ("Preposterous fd value %d", fd);
                                        ^~
netcat.c:1162:7: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      close (0);                /* so we won't need any more stdin */
      ^
netcat.c:1166:5: error: implicit declaration of function 'sleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    sleep (o_interval);         /* pause *before* sending stuff, too */
    ^
netcat.c:1184:28: warning: too few arguments in call to 'holler'
          holler ("select fuxored");
          ~~~~~~                  ^
netcat.c:1185:4: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          close (fd);
          ^
netcat.c:1196:27: warning: too few arguments in call to 'holler'
            holler ("net timeout");
            ~~~~~~               ^
netcat.c:1197:4: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          close (fd);
          ^
netcat.c:1207:7: error: implicit declaration of function 'farm9crypt_read' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        rr = farm9crypt_read (fd, bigbuf_net, BIGSIZ);
             ^
netcat.c:1229:7: error: implicit declaration of function 'read' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        rr = read (0, bigbuf_in, BIGSIZ);
             ^
netcat.c:1229:7: note: did you mean 'fread'?
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/stdio.h:158:9: note: 'fread' declared here
size_t   fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
61 warnings and 20 errors generated.
make[1]: *** [netcat.o] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_cryptcat/cryptcat/work/unix'
make: *** [darwin] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_cryptcat/cryptcat/work/unix'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_cryptcat/cryptcat/work/unix" && /usr/bin/make -j16 -w darwin 
Exit code: 2
Error: Failed to build cryptcat: command execution failed
DEBUG: Error code: CHILDSTATUS 6233 2

Change History (5)

comment:1 Changed 3 years ago by reneeotten (Renee Otten)

the first hit on Google tells you how to solve this - at least for close. It looks like there might be other issues though later on.... The port is nomaintainer, so if you want this fixed doing a bit of research and submitting a PR would be your best bet.

Last edited 3 years ago by reneeotten (Renee Otten) (previous) (diff)

comment:2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Resolution: fixed
Status: newclosed

In 2d56e4c35e7ca54122cfc044c0916d4bab47407c/macports-ports (master):

cryptcat: Fix implicit func decls; modernize

Fix implicit declaration of functions that prevented building with
Xcode 12+. Modernize checksums. Use "use_tar yes" instead of doing it
manually. Use leading 0 for octal numbers. Use makefile portgroup which
makes the port use the right compiler and flags and adds a universal
variant.

Closes: #63124

comment:3 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Fixed the immediate problems, but this software is old. The latest version is from 2005. There are a lot of warnings when compiling, some of which might be concerning. There's been no response from the developer(s) to several longstanding bug reports. Someone has left a comment on the SourceForge project page back in 2014 saying this software should not be used because its cryptography is bad, to which the developer(s) have not responded. I can't verify that claim, but the use of any cryptography software this old is probably not advisable.

comment:4 in reply to:  3 Changed 3 years ago by cooljeanius (Eric Gallager)

Replying to ryandesign:

Fixed the immediate problems, but this software is old. The latest version is from 2005. There are a lot of warnings when compiling, some of which might be concerning. There's been no response from the developer(s) to several longstanding bug reports. Someone has left a comment on the SourceForge project page back in 2014 saying this software should not be used because its cryptography is bad, to which the developer(s) have not responded. I can't verify that claim, but the use of any cryptography software this old is probably not advisable.

Well that's probably worth putting in the port's long_description then, and/or a note that's shown by port notes.

comment:5 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Or at least using the obsolete portgroup to print a boilerplate message. Feel free to submit a pull request.

Note: See TracTickets for help on using tickets.