Skip to content

Commit

Permalink
MONGOCRYPT-247 add ssize_t checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinAlbs committed Feb 11, 2020
1 parent 3446d45 commit 90ce62d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions kms-message/src/kms_message/kms_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef KMS_MESSAGE_H
#define KMS_MESSAGE_H

#include <sys/types.h>

#include "kms_message_defines.h"
#include "kms_request_opt.h"
#include "kms_request.h"
Expand Down
28 changes: 28 additions & 0 deletions kms-message/src/kms_message/kms_message_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,32 @@ kms_message_cleanup (void);
} /* extern "C" */
#endif

#ifdef _MSC_VER
#include <basetsd.h>
#ifndef __cplusplus
/* benign redefinition of type */
#pragma warning(disable : 4142)
#ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED
typedef SSIZE_T ssize_t;
#endif
#ifndef _SIZE_T_DEFINED
#define _SIZE_T_DEFINED
typedef SIZE_T size_t;
#endif
#pragma warning(default : 4142)
#else
/*
* MSVC++ does not include ssize_t, just size_t.
* So we need to synthesize that as well.
*/
#pragma warning(disable : 4142)
#ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED
typedef SSIZE_T ssize_t;
#endif
#pragma warning(default : 4142)
#endif
#endif

#endif /* KMS_MESSAGE_DEFINES_H */
5 changes: 0 additions & 5 deletions kms-message/src/kms_request_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
#include <stdint.h>
#include <string.h>

#if defined(_WIN32)
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif // _WIN32

typedef struct {
char *str;
size_t len;
Expand Down

0 comments on commit 90ce62d

Please sign in to comment.