diff options
-rw-r--r-- | desktop/win32/source/applauncher/launcher.cxx | 4 | ||||
-rw-r--r-- | desktop/win32/source/loader.cxx | 3 | ||||
-rw-r--r-- | desktop/win32/source/unoinfo.cxx | 3 | ||||
-rw-r--r-- | include/systools/win32/extended_max_path.hxx | 20 | ||||
-rw-r--r-- | odk/source/unoapploader/win/unoapploader.c | 3 | ||||
-rw-r--r-- | pyuno/source/loader/pyuno_loader.cxx | 12 | ||||
-rw-r--r-- | pyuno/zipcore/python.cxx | 3 | ||||
-rw-r--r-- | sal/osl/all/log.cxx | 3 | ||||
-rw-r--r-- | shell/source/win32/jumplist/JumpList.cxx | 5 | ||||
-rw-r--r-- | shell/source/win32/shlxthandler/shlxthdl.cxx | 4 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 3 | ||||
-rw-r--r-- | shell/source/win32/spsupp/spsuppHelper.cxx | 3 | ||||
-rw-r--r-- | shell/source/win32/spsupp/spsuppServ.cxx | 8 | ||||
-rw-r--r-- | vcl/win/dtrans/FmtFilter.cxx | 5 |
14 files changed, 60 insertions, 19 deletions
diff --git a/desktop/win32/source/applauncher/launcher.cxx b/desktop/win32/source/applauncher/launcher.cxx index 044b02d1ef33..1ec8caf13555 100644 --- a/desktop/win32/source/applauncher/launcher.cxx +++ b/desktop/win32/source/applauncher/launcher.cxx @@ -23,6 +23,8 @@ #include <stdlib.h> #include <malloc.h> +#include <systools/win32/extended_max_path.hxx> + extern "C" int APIENTRY wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) { // Retrieve startup info @@ -40,7 +42,7 @@ extern "C" int APIENTRY wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) // Calculate application name - WCHAR szThisAppName[32767]; + WCHAR szThisAppName[EXTENDED_MAX_PATH]; GetModuleFileNameW(nullptr, szThisAppName, std::size(szThisAppName)); std::filesystem::path soffice_exe(szThisAppName); soffice_exe.replace_filename(L"soffice.exe"); diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx index 047fb6b59210..81dfb7ed8d09 100644 --- a/desktop/win32/source/loader.cxx +++ b/desktop/win32/source/loader.cxx @@ -26,6 +26,7 @@ #include <string_view> #include <vector> #include <desktop/exithelper.h> +#include <systools/win32/extended_max_path.hxx> #include <systools/win32/uwinapi.h> #include <tools/pathutils.hxx> @@ -136,7 +137,7 @@ WCHAR* commandLineAppend(WCHAR* buffer, std::wstring_view text) // current executable. [[nodiscard]] std::pair<std::wstring, std::wstring> extendLoaderEnvironment() { - std::vector<wchar_t> executable_path(32767); + std::vector<wchar_t> executable_path(EXTENDED_MAX_PATH); DWORD exe_len; for (;;) { diff --git a/desktop/win32/source/unoinfo.cxx b/desktop/win32/source/unoinfo.cxx index 60cb574d7010..e44881faab12 100644 --- a/desktop/win32/source/unoinfo.cxx +++ b/desktop/win32/source/unoinfo.cxx @@ -25,6 +25,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <systools/win32/extended_max_path.hxx> #include <tools/pathutils.hxx> namespace { @@ -58,7 +59,7 @@ void writePath(std::wstring_view front, std::wstring_view back) } int wmain(int argc, wchar_t ** argv, wchar_t **) { - wchar_t path_buf[32767]; + wchar_t path_buf[EXTENDED_MAX_PATH]; if (argc == 2 && wcscmp(argv[1], L"c++") == 0) { auto path = getBrandPath(path_buf); writePath(path, L""); diff --git a/include/systools/win32/extended_max_path.hxx b/include/systools/win32/extended_max_path.hxx new file mode 100644 index 000000000000..9acbe58a5d7a --- /dev/null +++ b/include/systools/win32/extended_max_path.hxx @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#ifdef _WIN32 + +// The approximate maximum of Windows API, as documented in +// https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation +#define EXTENDED_MAX_PATH 32767 + +#endif // _WIN32 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/odk/source/unoapploader/win/unoapploader.c b/odk/source/unoapploader/win/unoapploader.c index 1b02775165b9..67c684b86d8a 100644 --- a/odk/source/unoapploader/win/unoapploader.c +++ b/odk/source/unoapploader/win/unoapploader.c @@ -30,6 +30,7 @@ #include <cppuhelper/findsofficepath.h> #include <sal/types.h> +#include <systools/win32/extended_max_path.hxx> #define MY_SIZE(s) (sizeof (s) / sizeof *(s)) #define MY_LENGTH(s) (MY_SIZE(s) - 1) @@ -72,7 +73,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, if ( path != NULL ) { - wchar_t cmd[32767]; + wchar_t cmd[EXTENDED_MAX_PATH]; /* hopefully does not overflow */ cmd[0] = L'"'; wcscpy(cmd + 1, path); diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index 7c04a376f43e..008d58634947 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -39,11 +39,17 @@ #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> +#include <systools/win32/extended_max_path.hxx> + // apparently PATH_MAX is not standard and not defined by MSVC -#ifndef PATH_MAX #ifdef _WIN32 -#define PATH_MAX 32767 -#elif defined _MAX_PATH +#ifdef PATH_MAX +#undef PATH_MAX +#endif +#define PATH_MAX EXTENDED_MAX_PATH +#endif +#ifndef PATH_MAX +#if defined _MAX_PATH #define PATH_MAX _MAX_PATH #elif defined MAX_PATH #define PATH_MAX MAX_PATH diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx index 93152fd9970c..77c2e0031b61 100644 --- a/pyuno/zipcore/python.cxx +++ b/pyuno/zipcore/python.cxx @@ -26,6 +26,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <systools/win32/extended_max_path.hxx> #include <tools/pathutils.hxx> #define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1) @@ -64,7 +65,7 @@ static wchar_t * encode(wchar_t * buffer, wchar_t const * text) { } int wmain(int argc, wchar_t ** argv, wchar_t **) { - wchar_t path[32767]; + wchar_t path[EXTENDED_MAX_PATH]; DWORD n = GetModuleFileNameW(nullptr, path, std::size(path)); if (n == 0 || n >= std::size(path)) { exit(EXIT_FAILURE); diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx index d014b2950d3e..a8b86e3e7e79 100644 --- a/sal/osl/all/log.cxx +++ b/sal/osl/all/log.cxx @@ -32,6 +32,7 @@ #elif defined _WIN32 #include <process.h> #include <windows.h> +#include <systools/win32/extended_max_path.hxx> #define OSL_DETAIL_GETPID _getpid() #else #include <unistd.h> @@ -91,7 +92,7 @@ char const * toString(sal_detail_LogLevel level) { char const* setEnvFromLoggingIniFile(const char* env, const char* key) { char const* sResult = nullptr; - wchar_t buffer[32767]; + wchar_t buffer[EXTENDED_MAX_PATH]; DWORD nLen = GetModuleFileNameW(nullptr, buffer, std::size(buffer)); if (nLen == 0 || nLen >= std::size(buffer)) return sResult; diff --git a/shell/source/win32/jumplist/JumpList.cxx b/shell/source/win32/jumplist/JumpList.cxx index 182af345c18e..d81aa1aa16e4 100644 --- a/shell/source/win32/jumplist/JumpList.cxx +++ b/shell/source/win32/jumplist/JumpList.cxx @@ -24,6 +24,7 @@ #include <osl/process.h> #include <sal/log.hxx> #include <systools/win32/comtools.hxx> +#include <systools/win32/extended_max_path.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -477,13 +478,13 @@ Sequence<JumpListItem> SAL_CALL JumpListImpl::getRemovedItems(const OUString& sA item.arguments = o3tl::toU(PropVariantToStringWithDefault(propvar, L"")); PropVariantClear(&propvar); - wchar_t itemDesc[32767]; + wchar_t itemDesc[EXTENDED_MAX_PATH]; ThrowIfFailed(pShellLinkItem->GetDescription( itemDesc, std::extent<decltype(itemDesc)>::value), "GetDescription failed."); item.description = o3tl::toU(itemDesc); - wchar_t path[32767]; + wchar_t path[EXTENDED_MAX_PATH]; int icon_index; ThrowIfFailed(pShellLinkItem->GetIconLocation( path, std::extent<decltype(path)>::value, &icon_index), diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx index 13f687ad5a6b..d794e9f800b7 100644 --- a/shell/source/win32/shlxthandler/shlxthdl.cxx +++ b/shell/source/win32/shlxthandler/shlxthdl.cxx @@ -30,6 +30,8 @@ #include <olectl.h> // declarations of DllRegisterServer/DllUnregisterServer +#include <systools/win32/extended_max_path.hxx> + // Module global LONG g_DllRefCnt = 0; @@ -300,7 +302,7 @@ namespace /* private */ STDAPI DllRegisterServer() { - WCHAR ModuleFileName[32767]; + WCHAR ModuleFileName[EXTENDED_MAX_PATH]; GetModuleFileNameW( GetCurrentModuleHandle(), diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index 333277353d03..b74425a155b5 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/system/XSimpleMailMessage2.hpp> #include <osl/file.hxx> #include <o3tl/char16_t2wchar_t.hxx> +#include <systools/win32/extended_max_path.hxx> #include <tools/urlobj.hxx> #include <unotools/pathoptions.hxx> #include <unotools/syslocale.hxx> @@ -67,7 +68,7 @@ namespace /* private */ LONG lret = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\LibreOffice\\SendAsEMailClient", &hkey); if (lret == ERROR_SUCCESS) { - wchar_t buff[32767]; + wchar_t buff[EXTENDED_MAX_PATH]; LONG sz = sizeof(buff); lret = RegQueryValueW(hkey, nullptr, buff, &sz); if (lret == ERROR_SUCCESS) diff --git a/shell/source/win32/spsupp/spsuppHelper.cxx b/shell/source/win32/spsupp/spsuppHelper.cxx index 9ee49401a3c8..5867a5ea393d 100644 --- a/shell/source/win32/spsupp/spsuppHelper.cxx +++ b/shell/source/win32/spsupp/spsuppHelper.cxx @@ -16,6 +16,7 @@ #include <osl/file.hxx> #include <rtl/bootstrap.hxx> #include <spsuppStrings.hrc> +#include <systools/win32/extended_max_path.hxx> #include <unotools/resmgr.hxx> #include "res/spsuppDlg.h" @@ -31,7 +32,7 @@ const OUString& GetSofficeExe() { static const OUString s_sPath = []() { OUString result; - wchar_t sPath[32767]; + wchar_t sPath[EXTENDED_MAX_PATH]; if (GetModuleFileNameW(nullptr, sPath, std::size(sPath)) == 0) return result; wchar_t* pSlashPos = wcsrchr(sPath, L'\\'); diff --git a/shell/source/win32/spsupp/spsuppServ.cxx b/shell/source/win32/spsupp/spsuppServ.cxx index f2afd288e5bb..17d0797ed98e 100644 --- a/shell/source/win32/spsupp/spsuppServ.cxx +++ b/shell/source/win32/spsupp/spsuppServ.cxx @@ -28,6 +28,8 @@ #include <shlwapi.h> // declaration of DllInstall +#include <systools/win32/extended_max_path.hxx> + namespace { HANDLE g_hModule; @@ -40,7 +42,7 @@ ITypeLib* GetTypeLib() typedef std::unique_ptr<ITypeLib, void(*)(IUnknown* p)> ITypeLibGuard; static ITypeLibGuard s_aITypeLibGuard = [] { ITypeLibGuard aITypeLibGuard(nullptr, [](IUnknown* p) { if (p) p->Release(); }); - wchar_t szFile[32767]; + wchar_t szFile[EXTENDED_MAX_PATH]; if (GetModuleFileNameW(GetHModule(), szFile, std::size(szFile)) == 0) return aITypeLibGuard; ITypeLib* pTypeLib; @@ -55,7 +57,7 @@ ITypeLib* GetTypeLib() const wchar_t* GetHelperExe() { static wchar_t* s_sPath = []() -> wchar_t* { - static wchar_t sPath[32767]; + static wchar_t sPath[EXTENDED_MAX_PATH]; if (GetModuleFileNameW(GetHModule(), sPath, std::size(sPath)) == 0) return nullptr; wchar_t* pSlashPos = wcsrchr(sPath, L'\\'); @@ -120,7 +122,7 @@ STDAPI DllRegisterServer(void) if (!pTypeLib) return ResultFromScode(SELFREG_E_TYPELIB); - wchar_t szFile[32767]; + wchar_t szFile[EXTENDED_MAX_PATH]; if (GetModuleFileNameW(GetHModule(), szFile, std::size(szFile)) == 0) return HRESULT_FROM_WIN32(GetLastError()); diff --git a/vcl/win/dtrans/FmtFilter.cxx b/vcl/win/dtrans/FmtFilter.cxx index 59e9d0beda51..6cd625fe6b91 100644 --- a/vcl/win/dtrans/FmtFilter.cxx +++ b/vcl/win/dtrans/FmtFilter.cxx @@ -36,6 +36,7 @@ #include <iomanip> #include <systools/win32/comtools.hxx> +#include <systools/win32/extended_max_path.hxx> using namespace com::sun::star::uno; @@ -322,7 +323,7 @@ static std::wstring getShellLinkTarget(const std::wstring& aLnkFile) if (FAILED(hr)) return target; - wchar_t pathW[32767]; + wchar_t pathW[EXTENDED_MAX_PATH]; WIN32_FIND_DATAW wfd; hr = pIShellLink->GetPath(pathW, std::size(pathW), &wfd, SLGP_RAWPATH); if (FAILED(hr)) @@ -381,7 +382,7 @@ css::uno::Sequence<sal_Int8> CF_HDROPToFileList(HGLOBAL hGlobal) for (UINT i = 0; i < nFiles; i++) { - wchar_t buff[32767]; + wchar_t buff[EXTENDED_MAX_PATH]; /*UINT size =*/ DragQueryFileW(static_cast<HDROP>(hGlobal), i, buff, std::size(buff)); std::wstring filename = buff; if (isShellLink(filename)) |