Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with 'p11_path_absolute()' #455

Open
gvanem opened this issue Feb 23, 2023 · 2 comments
Open

Issue with 'p11_path_absolute()' #455

gvanem opened this issue Feb 23, 2023 · 2 comments

Comments

@gvanem
Copy link

gvanem commented Feb 23, 2023

I've build this p11-kit for MSVC and clang-cl (on Win-10). But some tests aborts on an
absolute module path which this library claims is relative:

(p11-kit:9788) p11_kit_module_load: in: F:/MinGW32/src/inet/Crypto/p11-kit/bin/.libs/mock-one.dll
(p11-kit:9788) load_module_from_file_inlock: module path is relative, loading from: F:/MinGW32/src/inet/Crypto/p11-kit/bin/.libs
(p11-kit:9788) load_module_from_file_inlock: loading module from path: F:/MinGW32/src/inet/Crypto/p11-kit/bin/.libs\F:/MinGW32/src/inet/Crypto/p11-kit/bin/.libs/mock-one.dll
...

(built with -DWITH_DEBUG)

And a LoadLibrary() off-course fails. Since when are absolute paths on Windows not allowed to start with a /?
So with this little patch, all test succeeds:

--- a/common/path.c 2023-02-22 07:00:10
+++ b/common/path.c 2023-02-23 13:45:28
@@ -195,7 +195,7 @@

        return (path[0] == '/')
 #ifdef OS_WIN32
-       || (path[0] != '\0' && path[1] == ':' && path[2] == '\\')
+       || (path[0] != '\0' && path[1] == ':' && is_path_separator(path[2]))
 #endif
        ;
 }
@gvanem
Copy link
Author

gvanem commented Feb 23, 2023

all test succeeds:

I was a bit hasty. Perhaps related; with a set TMPDIR=c:/temp, test-transport.exe and test-proxy.exe fails:

1..44
# couldn't create temp directory: c:/temp\p11-test-transport.cBQArf: No such file or directory
Assertion failed: false && "this code should not be reached", file common/test.c, line 458

Yikes!

@gvanem
Copy link
Author

gvanem commented May 2, 2023

Yikes!

The above could be caused by a %TEMP% containing \\ (as my normal %TEMP% do).
But I patched it like this:

--- a/common/compat.c 2023-05-02 06:56:10
+++ b/common/compat.c 2023-05-02 09:01:18
@@ -744,7 +744,7 @@
        trv -= slen;
        suffp = trv;
        --trv;
-       if (trv < path || NULL != strchr (suffp, '/')) {
+       if (trv < path || strchr (suffp, '/') || strchr (suffp, '\\')) {
                errno = EINVAL;
                return (0);
        }
@@ -764,9 +764,12 @@
         */
        if (doopen != NULL || domkdir) {
                for (; trv > path; --trv) {
-                       if (*trv == '/') {
+                       if (*trv == '/' || *trv == '\\') {
                                *trv = '\0';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants