diff options
author | Werner Koch <[email protected]> | 2025-04-04 13:32:56 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-04-04 13:32:56 +0000 |
commit | a4a692fcf1ed128693ec6d64d5e3163775aad10b (patch) | |
tree | 39b0c09ca589396baa283dd328a2938c42741658 | |
parent | Add test cases for the strlist functions. (diff) | |
download | libgpg-error-a4a692fcf1ed128693ec6d64d5e3163775aad10b.tar.gz libgpg-error-a4a692fcf1ed128693ec6d64d5e3163775aad10b.zip |
w32: Improve the detection of the need for a \\?\ prefix
* src/sysutils.c (_gpgrt_fname_to_wchar): Use the no-max-path prefix
for shorter files and for filenames with path separators.
--
Depending on the current directory the old threshold of 230 was to
larger. Now we use a lower limit which should handle most standard
file names w/o the need for the prefix. We also always do this if the
requested file includes a directory part.
Updates-commit: 32dad4e4135f0bdc436ed684da753d4b0cdb0ea1
-rw-r--r-- | src/sysutils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/sysutils.c b/src/sysutils.c index 8eee084..132f1d3 100644 --- a/src/sysutils.c +++ b/src/sysutils.c @@ -256,8 +256,10 @@ _gpgrt_setenv (const char *name, const char *value, int overwrite) /* Convert an UTF-8 encode file name to wchar. If the file name is * close to the limit of MAXPATH the API functions will fail. The * method to overcome this API limitation is to use a prefix which - * bypasses the checking by CreateFile. This also required to first - * convert the name to an absolute file name. */ + * bypasses the checking by CreateFile. This also requires to first + * convert the name to an absolute file name. To avoid looking up the + * fill name in all cases we do the \\?\ prefixing only if FNAME is + * longer than 60 byes or if it has any path separator. */ wchar_t * _gpgrt_fname_to_wchar (const char *fname) { @@ -271,7 +273,7 @@ _gpgrt_fname_to_wchar (const char *fname) if (!strncmp (fname, "\\\\?\\", 4)) success = 1; /* Already translated. */ - else if (wcslen (wname) > 230) + else if (strpbrk (fname, "/\\") || wcslen (wname) > 60) { int wlen = 1024; int extralen; |