Jim Meyering <[EMAIL PROTECTED]> writes: > Simon Josefsson <[EMAIL PROTECTED]> wrote: >> Yoann Vandoorselaere <[EMAIL PROTECTED]> writes: >> >>> warning: getaddrinfo is LGPL but depend on intprops which is GPL >>> warning: inttostr is LGPL but depend on intprops which is GPL >> >> Jim, Paul, is it possible to have intprops be under LGPL? The >> alternative solution I see is to revert the patch for getaddrinfo that >> made it use inttostr (which needs intprops), and use sprintf instead. > > Here's a work-around: remove the inclusion of intprops.h > and add a simpler, slightly pessimistic definition instead: > > #define INT_BUFLEN_BOUND(t) ((sizeof (t) * CHAR_BIT) * 146 / 485 + 1 + 1)
So instead of if (snprintf (service, servicelen, "%d", ntohs (((const struct sockaddr_in *) sa)->sin_port)) + 1 > servicelen) return EAI_OVERFLOW; we'd have #define INT_BUFLEN_BOUND(t) ((sizeof (t) * CHAR_BIT) * 146 / 485 + 1 + 1) ... unsigned short int port = ntohs (((const struct sockaddr_in *) sa)->sin_port); char buf[INT_BUFSIZE_BOUND (port)]; char const *s = uinttostr (port, buf); if (strlen (s) + 1 > servicelen) return EAI_OVERFLOW; memcpy (service, s, strlen (s) + 1); right? That still uses uinttostr which is from the inttostr module which depends on and uses the intprops module, so it would still need GPL'd code in a possibly LGPL'd project. I'm starting to feel that we should revert to the old code in getaddrinfo. It was shorter and more readable, hence more maintainable. snprintf() is C99 and POSIX, and there is a working replacement for it in gnulib, under the LGPL. /Simon