Issue #17599: Use unique _Py_REPARSE_DATA_BUFFER etc names to avoid conflict

The conflict occurs with Min GW, which already defines REPARSE_DATA_BUFFER.
Also, Min GW uses a lowercase <windows.h> filename.
This commit is contained in:
Martin Panter 2016-08-04 02:38:59 +00:00
parent 0c859f362c
commit 70214ad55d
4 changed files with 20 additions and 16 deletions

View file

@ -14,6 +14,9 @@ Core and Builtins
- Issue #17596: Include <wincrypt.h> to help with Min GW building. - Issue #17596: Include <wincrypt.h> to help with Min GW building.
- Issue #17599: On Windows, rename the privately defined REPARSE_DATA_BUFFER
structure to avoid conflicting with the definition from Min GW.
- Issue #27507: Add integer overflow check in bytearray.extend(). Patch by - Issue #27507: Add integer overflow check in bytearray.extend(). Patch by
Xiang Zhang. Xiang Zhang.

View file

@ -486,7 +486,7 @@ _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
const USHORT prefix_len = 4; const USHORT prefix_len = 4;
USHORT print_len = 0; USHORT print_len = 0;
USHORT rdb_size = 0; USHORT rdb_size = 0;
PREPARSE_DATA_BUFFER rdb = NULL; _Py_PREPARSE_DATA_BUFFER rdb = NULL;
/* Junction point creation */ /* Junction point creation */
HANDLE junction = NULL; HANDLE junction = NULL;
@ -542,18 +542,18 @@ _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
- the size of the print name in bytes - the size of the print name in bytes
- the size of the substitute name in bytes - the size of the substitute name in bytes
- the size of two NUL terminators in bytes */ - the size of two NUL terminators in bytes */
rdb_size = REPARSE_DATA_BUFFER_HEADER_SIZE + rdb_size = _Py_REPARSE_DATA_BUFFER_HEADER_SIZE +
sizeof(rdb->MountPointReparseBuffer) - sizeof(rdb->MountPointReparseBuffer) -
sizeof(rdb->MountPointReparseBuffer.PathBuffer) + sizeof(rdb->MountPointReparseBuffer.PathBuffer) +
/* Two +1's for NUL terminators. */ /* Two +1's for NUL terminators. */
(prefix_len + print_len + 1 + print_len + 1) * sizeof(WCHAR); (prefix_len + print_len + 1 + print_len + 1) * sizeof(WCHAR);
rdb = (PREPARSE_DATA_BUFFER)PyMem_RawMalloc(rdb_size); rdb = (_Py_PREPARSE_DATA_BUFFER)PyMem_RawMalloc(rdb_size);
if (rdb == NULL) if (rdb == NULL)
goto cleanup; goto cleanup;
memset(rdb, 0, rdb_size); memset(rdb, 0, rdb_size);
rdb->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; rdb->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
rdb->ReparseDataLength = rdb_size - REPARSE_DATA_BUFFER_HEADER_SIZE; rdb->ReparseDataLength = rdb_size - _Py_REPARSE_DATA_BUFFER_HEADER_SIZE;
rdb->MountPointReparseBuffer.SubstituteNameOffset = 0; rdb->MountPointReparseBuffer.SubstituteNameOffset = 0;
rdb->MountPointReparseBuffer.SubstituteNameLength = rdb->MountPointReparseBuffer.SubstituteNameLength =
(prefix_len + print_len) * sizeof(WCHAR); (prefix_len + print_len) * sizeof(WCHAR);

View file

@ -1106,8 +1106,8 @@ _PyVerify_fd_dup2(int fd1, int fd2)
static int static int
win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag) win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
{ {
char target_buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; char target_buffer[_Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER *)target_buffer; _Py_REPARSE_DATA_BUFFER *rdb = (_Py_REPARSE_DATA_BUFFER *)target_buffer;
DWORD n_bytes_returned; DWORD n_bytes_returned;
if (0 == DeviceIoControl( if (0 == DeviceIoControl(
@ -7149,8 +7149,8 @@ win_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
int dir_fd; int dir_fd;
HANDLE reparse_point_handle; HANDLE reparse_point_handle;
char target_buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; char target_buffer[_Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER *)target_buffer; _Py_REPARSE_DATA_BUFFER *rdb = (_Py_REPARSE_DATA_BUFFER *)target_buffer;
const wchar_t *print_name; const wchar_t *print_name;
static char *keywords[] = {"path", "dir_fd", NULL}; static char *keywords[] = {"path", "dir_fd", NULL};

View file

@ -2,7 +2,7 @@
#define Py_WINREPARSE_H #define Py_WINREPARSE_H
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
#include <Windows.h> #include <windows.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -10,9 +10,10 @@ extern "C" {
/* The following structure was copied from /* The following structure was copied from
http://msdn.microsoft.com/en-us/library/ff552012.aspx as the required http://msdn.microsoft.com/en-us/library/ff552012.aspx as the required
include doesn't seem to be present in the Windows SDK (at least as included include km\ntifs.h isn't present in the Windows SDK (at least as included
with Visual Studio Express). */ with Visual Studio Express). Use unique names to avoid conflicting with
typedef struct _REPARSE_DATA_BUFFER { the structure as defined by Min GW. */
typedef struct {
ULONG ReparseTag; ULONG ReparseTag;
USHORT ReparseDataLength; USHORT ReparseDataLength;
USHORT Reserved; USHORT Reserved;
@ -38,11 +39,11 @@ typedef struct _REPARSE_DATA_BUFFER {
UCHAR DataBuffer[1]; UCHAR DataBuffer[1];
} GenericReparseBuffer; } GenericReparseBuffer;
}; };
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; } _Py_REPARSE_DATA_BUFFER, *_Py_PREPARSE_DATA_BUFFER;
#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\ #define _Py_REPARSE_DATA_BUFFER_HEADER_SIZE \
GenericReparseBuffer) FIELD_OFFSET(_Py_REPARSE_DATA_BUFFER, GenericReparseBuffer)
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) #define _Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
#ifdef __cplusplus #ifdef __cplusplus
} }