# HG changeset patch # User Yuya Nishihara # Date 2018-01-02 03:02:25 # Node ID 94a127152e2576ce11c56fba7fa3b6f870811d96 # Parent b14c8bcfbad9f95dd62736bf6c52958663fa5bab win32: allocate buffer of maximum length for GetVolumeInformation() It's documented that "the maximum buffer size is MAX_PATH+1", which is slightly larger than 256. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -8,6 +8,7 @@ from __future__ import absolute_import import ctypes +import ctypes.wintypes as wintypes import errno import msvcrt import os @@ -33,6 +34,7 @@ from . import ( _HANDLE = ctypes.c_void_p _HWND = _HANDLE _PCCERT_CONTEXT = ctypes.c_void_p +_MAX_PATH = wintypes.MAX_PATH _INVALID_HANDLE_VALUE = _HANDLE(-1).value @@ -460,7 +462,7 @@ def getfstype(path): _DRIVE_RAMDISK): return None - size = 256 + size = _MAX_PATH + 1 name = ctypes.create_string_buffer(size) if not _kernel32.GetVolumeInformationA(volume, None, 0, None, None, None,