bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH hurd 09/11] Fix overflow issues in tmpfs and vmallocate


From: Flavio Cruz
Subject: [PATCH hurd 09/11] Fix overflow issues in tmpfs and vmallocate
Date: Fri, 29 Dec 2023 16:21:03 -0500

---
 tmpfs/tmpfs.c      | 2 +-
 utils/vmallocate.c | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index 02d4bd8..d28806a 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -39,7 +39,7 @@ char *diskfs_disk_name = "none";
 int diskfs_default_sync_interval = 0;
 
 /* We must supply some claimed limits, though we don't impose any new ones.  */
-int diskfs_link_max = (1ULL << (sizeof (nlink_t) * CHAR_BIT)) - 1;
+int diskfs_link_max = INT_MAX;
 int diskfs_name_max = 255;     /* dirent d_namlen limit */
 int diskfs_maxsymlinks = 8;
 
diff --git a/utils/vmallocate.c b/utils/vmallocate.c
index b7eafed..fde8e76 100644
--- a/utils/vmallocate.c
+++ b/utils/vmallocate.c
@@ -160,8 +160,11 @@ main (int argc, char **argv)
   struct child *c, *children = NULL;
   process_t proc = getproc ();
 
-  /* We must make sure that chunk_size fits into vm_size_t.  */
-  assert_backtrace (chunk_size <= 1U << (sizeof (vm_size_t) * 8 - 1));
+  /* We must make sure that chunk_size fits into vm_size_t.
+   * We assume sizeof (vm_size_t) = sizeof (uintptr_t). */
+  _Static_assert (sizeof (vm_size_t) == sizeof (uintptr_t),
+      "expected sizeof (vm_size_t) == sizeof (uintptr_t).");
+  assert_backtrace (chunk_size <= UINTPTR_MAX);
 
   /* Parse our arguments.  */
   argp_parse (&argp, argc, argv, 0, 0, 0);
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]