View Ticket
Not logged in
2013-09-24
12:00 Closed ticket [3599194fff]: compat/fake-rfc2553.c is broken plus 7 other changes artifact: bc3d5c5bcf user: dkf
2013-02-24
03:01 Pending ticket [3599194fff]. artifact: 84e5e8ab06 user: nijtmans
2013-02-23
20:00
Bug [3599194]: compat/fake-rfc2553.c is broken check-in: 3f470535de user: jan.nijtmans tags: trunk
2013-01-02
20:14 Ticket [3599194fff] compat/fake-rfc2553.c is broken status still Open with 4 other changes artifact: 46111062a3 user: afredd
18:15 Ticket [3599194fff]: 4 changes artifact: 435b46d01d user: rmax
18:07 Ticket [3599194fff]: 1 change artifact: 4d29956cf9 user: nijtmans
10:44 New ticket [3599194fff]. artifact: 327e61d66a user: afredd

Ticket UUID: 3599194
Title: compat/fake-rfc2553.c is broken
Type: Bug Version: current: 8.6.0
Submitter: afredd Created on: 2013-01-02 10:44:01
Subsystem: 52. Portability Support Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2013-09-24 12:00:08
Resolution: Fixed Closed By: dkf
    Closed on: 2013-09-24 12:00:08
Description:
The function freeaddrinfo() in fake-rfc2553.c should be called fake_freeaddrinfo()
since the header file fake-rfc2553.h has:

#ifndef HAVE_FREEADDRINFO
#define freeaddrinfo(a)         (fake_freeaddrinfo(a))
void freeaddrinfo(struct addrinfo *);
#endif /* !HAVE_FREEADDRINFO */


When compiled it fails to find a definition for fake_freeaddrinfo!

Here is a patch diff to fix this and a couple of other issues the compiler found.


diff --git a/compat/fake-rfc2553.c b/compat/fake-rfc2553.c
index 666144f..3bb2834 100644
--- a/compat/fake-rfc2553.c
+++ b/compat/fake-rfc2553.c
@@ -84,7 +84,7 @@ int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,

        if (host != NULL) {
                if (flags & NI_NUMERICHOST) {
-                       int len;
+                       size_t len;
                        Tcl_MutexLock(&netdbMutex);
                        len = strlcpy(host, inet_ntoa(sin->sin_addr), hostlen);
                        Tcl_MutexUnlock(&netdbMutex);
@@ -135,7 +135,7 @@ fake_gai_strerror(int err)

 #ifndef HAVE_FREEADDRINFO
 void
-freeaddrinfo(struct addrinfo *ai)
+fake_freeaddrinfo(struct addrinfo *ai)
 {
        struct addrinfo *next;

@@ -199,7 +199,7 @@ fake_getaddrinfo(const char *hostname, const char *servname,

                port = strtol(servname, &cp, 10);
                if (port > 0 && port <= 65535 && *cp == '\0')
-                       port = htons(port);
+                       port = htons((unsigned short) port);
                else if ((sp = getservbyname(servname, NULL)) != NULL)
                        port = sp->s_port;
                else
User Comments: nijtmans added on 2013-02-24 03:01:58:
To me afredd's remarks all look valid. So, committed to trunk now.

Please confirm that everything is OK now.

afredd added on 2013-01-02 20:14:11:
> >Comment By: Reinhard Max (rmax)
> Date: 2013-01-02 03:15
> 
> Message:
> Thanks for your report, I'll have a look at it.
> Just out of curiosity: What platform building Tcl on that needs this
> fake-rfc2553 stuff?
> 

It's a 'unix' build option driven by the configured symbol NEED_FAKE_RFC2553.
In tclUnixPort.h there's:

  #ifdef NEED_FAKE_RFC2553
  # include "../compat/fake-rfc2553.h"
  #endif


However, i'm on a 32 bit Win XP machine :-)

Had to make a number of, er, hacks to make a git blead copy of Tcl
to build which included using the fake-rfc2553 stuff.
And yes i know this is not the Right Thing To Do. But i can at least
now play around with the code. (8.5 used to build just fine on this
machine without any hacks).

Not sure who _really_ needs this. The only way i can see how this
ever could have worked is if HAVE_FREEADDRINFO was also defined.
Then the (fake_)?freeaddrinfo() would not have been compiled in.


One more thing: the (unsigned short) cast in the call to htons()
should really be a (uint16_t) cast; however, then you should really
add a #include of <stdint.h> and i didn't want to further muddy
the waters.

rmax added on 2013-01-02 18:15:56:
Thanks for your report, I'll have a look at it.
Just out of curiosity: What platform building Tcl on that needs this fake-rfc2553 stuff?