aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-04-20 08:45:19 +0100
committerRon Yorston <rmy@pobox.com>2024-04-20 08:45:19 +0100
commitec3bd5c462717a6cd1668f536c8aab9d76ea04b0 (patch)
treeca8066750ece45e1e4b19801b30abd4a5ceb5d74
parent4fa00ce8a5b769acb5be4e6b13be713428ef23e4 (diff)
downloadbusybox-w32-ec3bd5c462717a6cd1668f536c8aab9d76ea04b0.tar.gz
busybox-w32-ec3bd5c462717a6cd1668f536c8aab9d76ea04b0.tar.bz2
busybox-w32-ec3bd5c462717a6cd1668f536c8aab9d76ea04b0.zip
win32: make stat(2) fail for /dev/zero, /dev/urandom
/dev/zero and /dev/urandom are only available internally and as arguments to 'dd'. Since users can't otherwise access them they shouldn't be treated as existing by stat(2). With this change stat(1) and test(1) will deny their existence. (GitHub issue #282)
-rw-r--r--win32/mingw.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index a8170bb9c..b1225665c 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -359,8 +359,9 @@ static int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fdata)
359{ 359{
360 char *want_dir; 360 char *want_dir;
361 361
362 if (get_dev_type(fname) != NOT_DEVICE || get_dev_fd(fname) >= 0) { 362 if (get_dev_type(fname) == DEV_NULL || get_dev_fd(fname) >= 0) {
363 /* Fake attributes for special devices */ 363 /* Fake attributes for special devices */
364 /* Though not /dev/zero or /dev/urandom */
364 FILETIME epoch = {0xd53e8000, 0x019db1de}; // Unix epoch as FILETIME 365 FILETIME epoch = {0xd53e8000, 0x019db1de}; // Unix epoch as FILETIME
365 fdata->dwFileAttributes = FILE_ATTRIBUTE_DEVICE; 366 fdata->dwFileAttributes = FILE_ATTRIBUTE_DEVICE;
366 fdata->ftCreationTime = fdata->ftLastAccessTime = 367 fdata->ftCreationTime = fdata->ftLastAccessTime =