aboutsummaryrefslogtreecommitdiff
path: root/src/include/port-sockets.h
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2018-10-04 18:10:48 -0400
committerGreg Hudson <ghudson@mit.edu>2018-10-28 19:57:28 -0400
commitf5bec0484b649e1114bdfa915d81cac9f2eca921 (patch)
treec459252d201e9e3d320f4a781a43c9e83116b52c /src/include/port-sockets.h
parentcfa1552d8bb8eedda94153dfb9f0ad154f01ba66 (diff)
downloadkrb5-krb5-1.13.zip
krb5-krb5-1.13.tar.gz
krb5-krb5-1.13.tar.bz2
Fix 64-bit Windows socket write error handlingkrb5-1.13
Add casts to ensure that the result type of SOCKET_WRITEV() on Windows can represent -1. Otherwise it will be treated as 2^32-1 when cast to ssize_t on 64-bit Windows, which can lead to crashes in krb5_sendto_kdc(). Reported by Puran Chand. (cherry picked from commit d98c3238894986765631f1e556f29ca817988816) ticket: 8746 version_fixed: 1.13.8
Diffstat (limited to 'src/include/port-sockets.h')
-rw-r--r--src/include/port-sockets.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/include/port-sockets.h b/src/include/port-sockets.h
index b3ab9c9..f0fc2b8 100644
--- a/src/include/port-sockets.h
+++ b/src/include/port-sockets.h
@@ -40,8 +40,9 @@ typedef WSABUF sg_buf;
*/
/* WSASend returns 0 or SOCKET_ERROR. */
#define SOCKET_WRITEV_TEMP DWORD
-#define SOCKET_WRITEV(FD, SG, LEN, TMP) \
- (WSASend((FD), (SG), (LEN), &(TMP), 0, 0, 0) ? -1 : (TMP))
+#define SOCKET_WRITEV(FD, SG, LEN, TMP) \
+ (WSASend((FD), (SG), (LEN), &(TMP), 0, 0, 0) ? \
+ (ssize_t)-1 : (ssize_t)(TMP))
#define SHUTDOWN_READ SD_RECEIVE
#define SHUTDOWN_WRITE SD_SEND