This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Fix buffer size error handling in gethostname.
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 29 May 2015 13:56:32 -0000
- Subject: [newlib-cygwin] Fix buffer size error handling in gethostname.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f7ddc49f40172ede26747c100b4132eb8680cf24
commit f7ddc49f40172ede26747c100b4132eb8680cf24
Author: Renato Silva <br.renatosilva@gmail.com>
Date: Tue Mar 31 21:18:46 2015 +0200
Fix buffer size error handling in gethostname.
* net.cc (cygwin_gethostname): Fix buffer size error handling.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/ChangeLog | 4 ++++
winsup/cygwin/net.cc | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 68171f6..c4be231 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-31 Renato Silva <br.renatosilva@gmail.com>
+
+ * net.cc (cygwin_gethostname): Fix buffer size error handling.
+
2015-03-31 Corinna Vinschen <corinna@vinschen.de>
* uinfo.cc (pwdgrp::fetch_account_from_windows): Don't allow fully
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index f9b317c..eaf6eb8 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1076,7 +1076,10 @@ cygwin_gethostname (char *name, size_t len)
if (!GetComputerNameExA (ComputerNameDnsFullyQualified, name,
&local_len))
{
- set_winsock_errno ();
+ if (GetLastError () == ERROR_MORE_DATA)
+ set_errno (ENAMETOOLONG);
+ else
+ set_winsock_errno ();
__leave;
}
}