Page MenuHome GnuPG

libassuan: uses of socklen_t in assuan.h are inconsistent
Closed, ResolvedPublic

Description

In assuan.h (the exposed API), there are uses of socklen_t and no-uses.

  • In some platform, socklen_t is not defined.
    • For the build of libassuan, it is properly addressed by configure, and config.h defines the result.
    • but the result is not exported to assuan.h
  • The API for assuan_sock_connect, assuan_sock_bind and assuan_sock_nonce should use socklen_t.
    • Other parts, connect method in struct assuan_system_hooks, __assuan_connect, and _assuan_npth_connect are using socklen_t

Event Timeline

gniibe triaged this task as Wishlist priority.Apr 8 2022, 3:38 AM
gniibe created this task.

I think that good approach as of 2022 is:

  • Don't support platform with no socklen_t any more
    • (On such a platform, using assuan.h has been requiring defining socklen_t before the inclusion of assuhan.h)
    • assuming socklen_t is always available
    • Thus, remove configure's checking of socklen_t
  • Use socklen_t for assuan.h properly
    • connect method in struct assuan_system_hooks
    • __assuan_connect
    • _assuan_npth_connect
    • This won't constitute API/ABI break on normal platforms with socklen_t == int
    • This will be API break on 32-bit platforms with socklen_t = some other 32-bit type, but not ABI break. (Are there any?)
    • This will be ABI break on platform where sizeof(socklen_t) != sizeof(int) (not likely, any)
gniibe changed the task status from Open to Testing.Jul 11 2024, 4:45 AM

The socklen_t use are now being fixed in newer POSIX Issue 8, 2024.
https://www.man7.org/linux/man-pages/man3/socklen_t.3type.html

Fixed in: rA69a703446b61: Use socklen_t for the length of socket address.

Users of assuan.h are required to have valid socklen_t definition if it's not available by system.

To be conservative, I keep gl_TYPE_SOCKLEN_T in configure.ac.

Fixed in libassuan 3.0.0.