Skip Menu |
 

Subject: WIN32 SOCKET != int in gss lib
A WIN32 SOCKET is a HANDLE type and is not equivalent in size to an
'int'. Windows SOCKET values frequently exceed MAX_INT and become
truncated.

convert all references to SOCKET and use closesocket() to release the
them instead of the C Runtime Library close() which only applies to file
descriptors.

Proposed patch attached.
Download gss-win32-socket-1.patch
application/octet-stream 6.4KiB

Message body not shown because it is not plain text.

Proposed patch approved, with discussed changes to use SOCKET/closesocket unconditionally,
anywhere but in the installed headers. (Don't forget to make sure port-sockets.h is included.)
RT-Send-CC: raeburn@mit.edu
[raeburn - Mon Jul 21 18:40:28 2008]:

Show quoted text
> Proposed patch approved, with discussed changes to use
> SOCKET/closesocket unconditionally,
> anywhere but in the installed headers. (Don't forget to make sure
> port-sockets.h is included.)

When you get an opportunity please try the attached patch,
rt6041-gssrpc-socket-2.patch

Thank you.
Download rt6041-gssrpc-socket-2.patch
application/octet-stream 7.1KiB

Message body not shown because it is not plain text.

From: Ken Raeburn <raeburn@MIT.EDU>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6041] WIN32 SOCKET != int in gss and rpc libs
Date: Wed, 23 Jul 2008 13:18:22 -0400
RT-Send-Cc:
closesocket returns an int as close does. If we're intentionally
ignoring the return values, please keep the (void) casts, at least for
now.

Why do you need to define INVALID_SOCKET in svc_udp.c?

Ken
Date: Wed, 23 Jul 2008 13:27:06 -0400
From: Jeffrey Altman <jaltman@mit.edu>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6041] WIN32 SOCKET != int in gss and rpc libs
RT-Send-Cc:
Ken Raeburn via RT wrote:
Show quoted text
> closesocket returns an int as close does. If we're intentionally
> ignoring the return values, please keep the (void) casts, at least for
> now.

sure although I don't understand why ignoring that return value should
be treated specially.

Show quoted text
> Why do you need to define INVALID_SOCKET in svc_udp.c?

INVALID_SOCKET is a special value on Windows which is architecture
dependent. Is INVALID_SOCKET defined somewhere else for Unix?
Take three.

(void) casting re-applied

INVALID_SOCKET defined in port-sockets.h and removed from .c file
Download rt6041-gssrpc-socket-3.patch
application/octet-stream 7.1KiB

Message body not shown because it is not plain text.

From: Ken Raeburn <raeburn@MIT.EDU>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6041] WIN32 SOCKET != int in gss and rpc libs
Date: Wed, 23 Jul 2008 16:36:51 -0400
RT-Send-Cc:
On Jul 23, 2008, at 13:25, Jeffrey Altman via RT wrote:
Show quoted text
> sure although I don't understand why ignoring that return value should
> be treated specially.

It's not that there's anything special about close/closesocket, I just
don't want to make removing such casts a part of this otherwise fairly
specific change, in the absence of a specific coding style guideline
regarding ignored return values.

Show quoted text
>> Why do you need to define INVALID_SOCKET in svc_udp.c?
>
> INVALID_SOCKET is a special value on Windows which is architecture
> dependent. Is INVALID_SOCKET defined somewhere else for Unix?

Yes, port-sockets.h already has a definition for the UNIX case.

The revised patch looks good, please check it in...

Ken
From: jaltman@mit.edu
Subject: SVN Commit

In the gss rpc package, replace the type used for a
socket on Windows with SOCKET (instead of int) and
replace all calls to close() that are used to close
sockets with closesocket().

src/include/port-sockets.h includes the definitions
of SOCKET and closesocket() for non-Windows systems.


Commit By: jaltman



Revision: 20578
Changed Files:
U trunk/src/include/gssrpc/svc.h
U trunk/src/lib/rpc/clnt_simple.c
U trunk/src/lib/rpc/clnt_tcp.c
U trunk/src/lib/rpc/clnt_udp.c
U trunk/src/lib/rpc/pmap_rmt.c
U trunk/src/lib/rpc/svc_tcp.c
U trunk/src/lib/rpc/svc_udp.c
Tom caught a problem I overlooked: clnttcp_create is a public interface. You updated the
function definition to take SOCKET*, but the declaration still says int*. Please update the header
(and since it gets installed, you can only use SOCKET for Windows environments, it has to stay
with int for UNIX).

You might also want to look into why compile-time warnings didn't catch this for you....