Re: Porting Bind
=?iso-8859-1?q?Dios=20Del=20Tiempo?= <cronos1_mx@yahoo.com> writes:
> Yes, but as long as I prefer to do the easiest part first, I'll start fix=
> ing
> the MAXHOSTNALELEN issue. To achieve this, I modified Neal's xgethostname=
> .c to
> add the hostnamecpy function; it copies a hostname to another string and
> enforces hostname length limits. Is it correct? If so, is it fine to add =
> it to
> Neal's library, or is better to write it separately? =20
Why do you think that this functionality is generally useful? I have not heard
of a hostnamecpy function before.
> +int
> +hostnamecpy (char *hostname, char **dest)
> +{
> + int size =3D 0;
> + int maxlen =3D 0;
> + int hostnamelen =3D strlen (hostname);
> +
> +#ifdef MAXHOSTNAMELEN
> + size =3D MAXHOSTNAMELEN;
> + maxlen =3D 1;
> +#else /* MAXHOSTNAMELEN */
> +#ifdef _SC_HOST_NAME_MAX
> + size =3D sysconf (_SC_HOST_NAME_MAX);
> + maxlen =3D 1;
> +#endif /* _SC_HOST_NAME_MAX */
> + if (size <=3D 0)
> + size =3D 255;
> +#endif /* MAXHOSTNAMELEN */
> +
> + if (maxlen && (hostnamelen > (size + 1)))
> + return ENAMETOOLONG;
This is broken. sysconf (_SC_HOST_NAME_MAX) returns -1 on the Hurd.
Reply to: