[newlib-cygwin] Cygwin: Return port number from getservent in network byte order

Corinna Vinschen corinna@sourceware.org
Tue Aug 18 11:12:00 GMT 2015


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=cb2ab5fd01265b2aa4a40865e4bd244f789328ff

commit cb2ab5fd01265b2aa4a40865e4bd244f789328ff
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Aug 18 13:12:07 2015 +0200

    Cygwin: Return port number from getservent in network byte order
    
            * netdb.cc (parse_services_line): Convert port number to network byte
            order.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/ChangeLog     | 5 +++++
 winsup/cygwin/netdb.cc      | 4 ++--
 winsup/cygwin/release/2.2.1 | 4 ++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index ba2b657..3e1518d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
 2015-08-18  Corinna Vinschen  <corinna@vinschen.de>
 
+	* netdb.cc (parse_services_line): Convert port number to network byte
+	order.
+
+2015-08-18  Corinna Vinschen  <corinna@vinschen.de>
+
 	* exceptions.cc: Drop including ucontext.h.
 
 2015-08-17  Corinna Vinschen  <corinna@vinschen.de>
diff --git a/winsup/cygwin/netdb.cc b/winsup/cygwin/netdb.cc
index 3e3b354..cc0a2ca 100644
--- a/winsup/cygwin/netdb.cc
+++ b/winsup/cygwin/netdb.cc
@@ -1,6 +1,6 @@
 /* netdb.cc: network database related routines.
 
-   Copyright 2002, 2003, 2007, 2008, 2010, 2011, 2013 Red Hat, Inc.
+   Copyright 2002, 2003, 2007, 2008, 2010, 2011, 2013, 2015 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -192,7 +192,7 @@ parse_services_line (FILE *svc_file, struct servent *sep)
       *protocol++ = '\0';
       sep->s_name = strdup (name);
       paranoid_printf ("sep->s_name strdup %p", sep->s_name);
-      sep->s_port = atoi (port);
+      sep->s_port = htons (atoi (port));
       sep->s_proto = strdup (protocol);
       paranoid_printf ("sep->s_proto strdup %p", sep->s_proto);
       /* parse_alias_list relies on side effects.  Read the comments
diff --git a/winsup/cygwin/release/2.2.1 b/winsup/cygwin/release/2.2.1
index 294e0c9..24a4b81 100644
--- a/winsup/cygwin/release/2.2.1
+++ b/winsup/cygwin/release/2.2.1
@@ -23,3 +23,7 @@ Bug Fixes
 
 - Include <sys/ucontext.h> from <sys/signal.h> if compiling for POSIX.1-2008.
   Addresses: https://cygwin.com/ml/cygwin/2015-08/msg00266.html
+
+- getservent(3) returned the port number in host byte order.  Change that to
+  network byte order as required.
+  Addresses: https://cygwin.com/ml/cygwin/2015-08/msg00301.html



More information about the Cygwin-cvs mailing list