]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wrapper.c
xgethostname: handle long hostnames
[thirdparty/git.git] / wrapper.c
index e7f197996868a614c84537ad96fc672ea901148d..64ebd6c690d70203578c0d928a1f1886ad2a6b0e 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -679,3 +679,16 @@ void sleep_millisec(int millisec)
 {
        poll(NULL, 0, millisec);
 }
+
+int xgethostname(char *buf, size_t len)
+{
+       /*
+        * If the full hostname doesn't fit in buf, POSIX does not
+        * specify whether the buffer will be null-terminated, so to
+        * be safe, do it ourselves.
+        */
+       int ret = gethostname(buf, len);
+       if (!ret)
+               buf[len - 1] = 0;
+       return ret;
+}