pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proper patching source code with HOST_NAME_MAX usage



On 2020-01-14 00:25, Matthias Petermann wrote:
> Hi there,
> 
> I developed a patch over the weekend to upgrade net/rdesktop to the
> current version 1.9.0. The version currently in pkgsrc has an unpleasant
> bug (https://github.com/rdesktop/rdesktop/issues/17)
> 
> The patch works, but I would like to clarify one detail before
> submitting. In the file xwin.c a variable hostname is defined in the
> method set_wm_client_machine in the following way:
> 
> char hostname [HOST_NAME_MAX];
> 
> The macro HOST_NAME_MAX does not exist in NetBSD. Instead, I read
> sysconf (_SC_HOST_NAME_MAX) should be used. My C course was two decades
> ago, but if I remember correctly I can't just use it instead of
> HOST_NAME_MAX.

You can do that in C99:
> #include <unistd.h>
> #include <stdio.h>
> 
> int main() {
>         char hostname[sysconf(_SC_HOST_NAME_MAX)];
>         printf("%d\n", sizeof(hostname));
>         return 0;
> }


Home | Main Index | Thread Index | Old Index