pkgsrc-Users archive

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

Proper patching source code with HOST_NAME_MAX usage



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.

So my question is: what is the best way to deal with it?

a) Use of MAXHOSTNAMELEN from sys/param.h

b) Convert the variable into a pointer variable and use allocation of the appropriate length at runtime? Disadvantage: memory would actually have to be released again, i.e. more intervention in the original source code than I actually want to do ..

c) is there anything more elegant that I don't know about yet?

I have essentially oriented myself towards [1] and appreciate comments.

Best wishes
Matthias


[1] https://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00108.html

--
Petermann IT / M. Petermann <mp%petermann-it.de@localhost> | www.petermann-it.de
Wildparkring 13, 01458 Ottendorf-Okrilla | Tel.: +49 (0)35205 597 991


Home | Main Index | Thread Index | Old Index