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>
This commit is contained in:
Corinna Vinschen 2015-08-18 13:12:07 +02:00
parent f9f3d44f27
commit cb2ab5fd01
3 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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> 2015-08-18 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc: Drop including ucontext.h. * exceptions.cc: Drop including ucontext.h.

View File

@ -1,6 +1,6 @@
/* netdb.cc: network database related routines. /* 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. This file is part of Cygwin.
@ -192,7 +192,7 @@ parse_services_line (FILE *svc_file, struct servent *sep)
*protocol++ = '\0'; *protocol++ = '\0';
sep->s_name = strdup (name); sep->s_name = strdup (name);
paranoid_printf ("sep->s_name strdup %p", sep->s_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); sep->s_proto = strdup (protocol);
paranoid_printf ("sep->s_proto strdup %p", sep->s_proto); paranoid_printf ("sep->s_proto strdup %p", sep->s_proto);
/* parse_alias_list relies on side effects. Read the comments /* parse_alias_list relies on side effects. Read the comments

View File

@ -23,3 +23,7 @@ Bug Fixes
- Include <sys/ucontext.h> from <sys/signal.h> if compiling for POSIX.1-2008. - Include <sys/ucontext.h> from <sys/signal.h> if compiling for POSIX.1-2008.
Addresses: https://cygwin.com/ml/cygwin/2015-08/msg00266.html 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