diff options
author | midipix <writeonce@midipix.org> | 2020-05-09 22:57:35 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2020-05-09 23:04:43 +0000 |
commit | 0443ad2b6ed839e8480e250a655001f7d403c9cb (patch) | |
tree | bd1dc22202609e3cec311b2a2e6b20aeee73dbcd /src/ldso | |
parent | 1ca6f15ee9908e1048d7accd4e0ed57d2019d851 (diff) | |
download | pemagine-0443ad2b6ed839e8480e250a655001f7d403c9cb.tar.bz2 pemagine-0443ad2b6ed839e8480e250a655001f7d403c9cb.tar.xz |
pe_get_device_dos_drive_letter(): open the drive, not the volume.
Opening the drive rather than the volume's top-level directory requires
reduced permissions, and so should always be preferred for as long as
it is sufficient.
This change, however, is also motivated by annoying media-drive driver
behavior of popping up a dialog (how awful) window whenever an allegedly
interactive application (that is, interactive by its subsystem) attempts
to access a directory (or a file) in the drive while it is empty.
Diffstat (limited to 'src/ldso')
-rw-r--r-- | src/ldso/pe_load_framework_loader.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ldso/pe_load_framework_loader.c b/src/ldso/pe_load_framework_loader.c index 347d3ab..4595b99 100644 --- a/src/ldso/pe_load_framework_loader.c +++ b/src/ldso/pe_load_framework_loader.c @@ -34,7 +34,7 @@ static int32_t pe_get_device_dos_drive_letter( wchar16_t namebuf[8] = { '\\','?','?','\\', - 'X',':','\\',0}; + 'X',':',0}; unsigned char letters[26] = { 'C','Z','Y','X','W','V', @@ -54,7 +54,7 @@ static int32_t pe_get_device_dos_drive_letter( /* path */ path.buffer = namebuf; - path.strlen = 7 * sizeof(wchar16_t); + path.strlen = 6 * sizeof(wchar16_t); path.maxlen = 0; /* oa */ @@ -72,13 +72,12 @@ static int32_t pe_get_device_dos_drive_letter( status = zw_open_file( &hdevice, OS_SEC_SYNCHRONIZE - | OS_FILE_READ_ATTRIBUTES - | OS_FILE_READ_ACCESS, + | OS_FILE_READ_ATTRIBUTES, &oa,&iosb, OS_FILE_SHARE_READ | OS_FILE_SHARE_WRITE | OS_FILE_SHARE_DELETE, - OS_FILE_DIRECTORY_FILE); + OS_FILE_SYNCHRONOUS_IO_ALERT); if (status == OS_STATUS_SUCCESS) { status = zw_query_object( @@ -92,17 +91,19 @@ static int32_t pe_get_device_dos_drive_letter( src = devname; dst = dpath->buffer; - idx = 0; - cap = devnamelen / sizeof(wchar16_t); + if (devnamelen == dpath->strlen) { + idx = 0; + cap = devnamelen / sizeof(wchar16_t); - for (; idx<cap && src[idx]==dst[idx]; ) - idx++; + for (; idx<cap && src[idx]==dst[idx]; ) + idx++; - if (idx==cap && dst[idx]=='\\') { - zw_close(hdevice); - *letter = letters[sigh]; + if (idx==cap) { + zw_close(hdevice); + *letter = letters[sigh]; - return OS_STATUS_SUCCESS; + return OS_STATUS_SUCCESS; + } } } |