[PATCH 4/4] Use gssalloc_malloc()/gssalloc_free() with gss_buffer_t.

Jeffrey Altman jaltman at secure-endpoints.com
Wed Sep 28 17:49:20 EDT 2011


In addition to Nico's comments, the following block appears to be
misplaced in this patchset.


On 9/28/2011 3:50 PM, Sam Hartman wrote:
> From: Kevin Wasserman <kevin.wasserman at painless-security.com>
> 
> gss_buffer_t may be freed in a different module from where they
> are allocated so it is not safe to use malloc/free.
> 
> Signed-off-by: Kevin Wasserman <kevin.wasserman at painless-security.com>
> diff --git a/src/appl/gss-sample/gss-misc.c b/src/appl/gss-sample/gss-misc.c
> index 98d2045..e124dcc 100644
> @@ -124,6 +125,64 @@ read_all(int fildes, char *buf, unsigned int nbyte)
>              return (ptr - buf);
>          ret = recv(fildes, ptr, nbyte, 0);
>          if (ret < 0) {
> +#ifdef _WIN32
> +            const char* msg = "Unknown error";
> +            int error_code = WSAGetLastError();
> +            switch (error_code)
> +            {
> +            case WSANOTINITIALISED:
> +                msg = "A successful WSAStartup call must occur before using this function.";
> +                break;
> +            case WSAENETDOWN:
> +                msg = "The network subsystem has failed.";
> +                break;
> +            case WSAEFAULT:
> +                msg = "The buf parameter is not completely contained in a valid part of the user address space.";
> +                break;
> +            case WSAENOTCONN:
> +                msg = "The socket is not connected.";
> +                break;
> +            case WSAEINTR:
> +                msg="The socket was closed.";
> +                break;
> +            case WSAEINPROGRESS:
> +                msg="A blocking Winsock call is in progress, or the service provider is still processing a callback function.";
> +                break;
> +            case WSAENETRESET:
> +                msg = "The connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress.";
> +                break;
> +            case WSAENOTSOCK:
> +                msg = "The descriptor is not a socket.";
> +                break;
> +            case WSAEOPNOTSUPP:
> +                msg = "MSG_OOB was specified, but the socket is not stream style such as type SOCK_STREAM, out of band (OOB) data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations.";
> +                break;
> +            case WSAESHUTDOWN:
> +                msg = "The socket has been shut down; it is not possible to receive on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH.";
> +                break;
> +            case WSAEWOULDBLOCK:
> +                msg = "The socket is marked as nonblocking and the receive operation would block.";
> +                break;
> +            case WSAEMSGSIZE:
> +                msg = "The message was too large to fit into the specified buffer and was truncated.";
> +                break;
> +            case WSAEINVAL:
> +                msg = "The socket has not been bound with bind (Windows Sockets), an unknown flag was specified, MSG_OOB was specified for a socket with SO_OOBINLINE enabled, or (for byte stream sockets only) len was zero or negative.";
> +                break;
> +            case WSAECONNABORTED:
> +                msg = "The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.";
> +                break;
> +            case WSAETIMEDOUT:
> +                msg = "The connection has been dropped because of a network failure or because the peer system failed to respond.";
> +                break;
> +            case WSAECONNRESET:
> +                msg = "The virtual circuit was reset by the remote side executing a hard or abortive close. The application should close the socket because it is no longer usable.";
> +                break;
> +            default:
> +                break;
> +            }
> +            perror(msg);
> +#endif
>              if (errno == EINTR)
>                  continue;
>              return (ret);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
Url : http://mailman.mit.edu/pipermail/krbdev/attachments/20110928/b0b3cf84/attachment.bin


More information about the krbdev mailing list