Re: [PATCH] xgethostname: handle long hostnames

2017-04-13 Thread René Scharfe
Am 13.04.2017 um 21:23 schrieb David Turner: > If the full hostname doesn't fit in the buffer supplied to > gethostname, POSIX does not specify whether the buffer will be > null-terminated, so to be safe, we should do it ourselves. Introduce > new function, xgethostname, which ensures that there i

RE: [PATCH] xgethostname: handle long hostnames

2017-04-13 Thread David Turner
> -Original Message- > From: Jonathan Nieder [mailto:jrnie...@gmail.com] > Sent: Thursday, April 13, 2017 6:05 PM > To: David Turner > Cc: git@vger.kernel.org > Subject: Re: [PATCH] xgethostname: handle long hostnames > > Hi, > > David Turner wrote: >

Re: [PATCH] xgethostname: handle long hostnames

2017-04-13 Thread Jonathan Nieder
Hi, David Turner wrote: > If the full hostname doesn't fit in the buffer supplied to > gethostname, POSIX does not specify whether the buffer will be > null-terminated, so to be safe, we should do it ourselves. [...] > +++ b/wrapper.c > @@ -655,3 +655,16 @@ void sleep_millisec(int millisec) > {

Re: [PATCH] xgethostname: handle long hostnames

2017-04-13 Thread Jeff King
On Thu, Apr 13, 2017 at 03:23:35PM -0400, David Turner wrote: > If the full hostname doesn't fit in the buffer supplied to > gethostname, POSIX does not specify whether the buffer will be > null-terminated Wow, TIL. What an utterly terrible and error-prone interface (I always just assumed we'd ge

[PATCH] xgethostname: handle long hostnames

2017-04-13 Thread David Turner
If the full hostname doesn't fit in the buffer supplied to gethostname, POSIX does not specify whether the buffer will be null-terminated, so to be safe, we should do it ourselves. Introduce new function, xgethostname, which ensures that there is always a \0 at the end of the buffer. Signed-off-b