bug-gnulib
[Top][All Lists]
Advanced

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

Re: missing strcpy prototype in gethostname module


From: Simon Josefsson
Subject: Re: missing strcpy prototype in gethostname module
Date: Thu, 17 Jan 2008 11:09:10 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> @@ -21,6 +21,8 @@
>>  
>>  #ifdef HAVE_UNAME
>>  # include <sys/utsname.h>
>> +#else
>> +# include <string.h>
>>  #endif
>>  
>>  /* Put up to LEN chars of the host name into NAME.
>
> While at it, you could make the patch complete: The function strncpy also
> needs to be declared somewhere.

Good point.  Patch below applied.

/Simon

diff --git a/ChangeLog b/ChangeLog
index 467fadb..776e8ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-17  Simon Josefsson  <address@hidden>
+
+       * lib/gethostname.c: Include string.h unconditionally, strncpy is
+       used by the UNAME case.  Reported by Bruno Haible
+       <address@hidden>.
+
 2008-01-17  Eric Blake  <address@hidden>
 
        Convert c-strcasestr to be more efficient.
diff --git a/lib/gethostname.c b/lib/gethostname.c
index de3d9a5..169dd4e 100644
--- a/lib/gethostname.c
+++ b/lib/gethostname.c
@@ -21,10 +21,10 @@
 
 #ifdef HAVE_UNAME
 # include <sys/utsname.h>
-#else
-# include <string.h>
 #endif
 
+#include <string.h>
+
 /* Put up to LEN chars of the host name into NAME.
    Null terminate it if the name is shorter than LEN.
    Return 0 if ok, -1 if error.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]