Port on AIX 32bit : unsigned int len; and __ulong32_t socklen_t

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Port on AIX 32bit : unsigned int len; and __ulong32_t socklen_t

REIX, Tony
Hi,

On AIX, in:
  src/appl/simple/client/sim_client.c
  src/appl/simple/server/sim_server.c

the following definition works in 64bit but not in 32bit:
   unsigned int len;
  if (getsockname(sock, (struct sockaddr *)&c_sock, &len) < 0) {

This is due to:
  /opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed/sys/socket.h :
  int     getsockname(int, struct sockaddr *__restrict__, socklen_t *__restrict__);
  typedef __ulong32_t socklen_t;
and:
  /usr/include/inttypes.h
#ifdef __64BIT__
typedef unsigned int    __ulong32_t;
#else
typedef unsigned long   __ulong32_t;
#endif /* __64BIT__ */


I do not know what happens on Linux/x86_64 in 32bit.
I'm looking at Linux/x86_64 now, using krb5-1.15.1-8.fc26.spec.
However I think that it builds by default in 64bit.

Moreover:
  - /root/rpmbuild/BUILD/gcc-7.1.0/fixincludes/tests/base/sys/socket.h
          does not contain any definition for getsockname()
  - __ulong32_t does not seem to exist on Linux.

So: if krb5 on Linux is always built in 64bit, and never in 32bit, the issue does not appear.
However, maybe that, even in 32bit, the issue does not appear. Unless some # if __WORDSIZE == 64  is required ?

Anyway, here is my (simple) patch for AIX.

Cordialement,

Tony Reix

Bull - ATOS
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net<http://www.atos.net/>

_______________________________________________
krbdev mailing list             [hidden email]
https://mailman.mit.edu/mailman/listinfo/krbdev

krb5-1.15.1-sim-unsigned_int_len.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Port on AIX 32bit : unsigned int len; and __ulong32_t socklen_t

Robbie Harwood
"REIX, Tony" <[hidden email]> writes:

> Hi,
>
> On AIX, in:
>   src/appl/simple/client/sim_client.c
>   src/appl/simple/server/sim_server.c
>
> the following definition works in 64bit but not in 32bit:
>    unsigned int len;
>   if (getsockname(sock, (struct sockaddr *)&c_sock, &len) < 0) {
>
> This is due to:
>   /opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed/sys/socket.h :
>   int     getsockname(int, struct sockaddr *__restrict__, socklen_t *__restrict__);
>   typedef __ulong32_t socklen_t;
> and:
>   /usr/include/inttypes.h
> #ifdef __64BIT__
> typedef unsigned int    __ulong32_t;
> #else
> typedef unsigned long   __ulong32_t;
> #endif /* __64BIT__ */
>
>
> I do not know what happens on Linux/x86_64 in 32bit.
> I'm looking at Linux/x86_64 now, using krb5-1.15.1-8.fc26.spec.
> However I think that it builds by default in 64bit.
krb5-1.15.1 builds fine on both 32 and 64-bit Linux.  POSIX[1] states:

     <sys/socket.h> makes available a type, socklen_t, which is an
     unsigned opaque integral type of length of at least 32 bits. To
     forestall portability problems, it is recommended that applications
     should not use values larger than 2^32 - 1.

> Moreover:
>   - /root/rpmbuild/BUILD/gcc-7.1.0/fixincludes/tests/base/sys/socket.h
>           does not contain any definition for getsockname()

I would expect that to be at /usr/include/sys/socket.h on Fedora, and
it's declared as:

    /* Put the local address of FD into *ADDR and its length in *LEN.  */
    extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
                            socklen_t *__restrict __len) __THROW;

(It comes out of the glibc-headers package.)

> So: if krb5 on Linux is always built in 64bit, and never in 32bit, the issue does not appear.
> However, maybe that, even in 32bit, the issue does not appear. Unless
> some # if __WORDSIZE == 64  is required ?

krb5 has abstraction around getsockname's third type.  The #define to
look for is GETSOCKNAME_ARG3_TYPE; there are some rules in aclocal.m4
for determining it.

Thanks,
--Robbie

_______________________________________________
krbdev mailing list             [hidden email]
https://mailman.mit.edu/mailman/listinfo/krbdev

signature.asc (847 bytes) Download Attachment