34 lines
1.3 KiB
Diff
34 lines
1.3 KiB
Diff
From c357ca7be7cd70c4b62c1889f7f110d50a85aa02 Mon Sep 17 00:00:00 2001
|
|
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
|
|
Date: Sun, 18 Aug 2024 06:18:40 -0500
|
|
Subject: [PATCH 33/34] recurse-dir: Perform correct pointer math on de
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Without this, we are casting the pointer math itself to struct dirent*
|
|
which causes invalid calculations on systems with structs aligned to a
|
|
different width than uint8_t* (i.e. ppc64).
|
|
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
src/basic/recurse-dir.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c
|
|
index 776733148b05..8c4b044ea0fb 100644
|
|
--- a/src/basic/recurse-dir.c
|
|
+++ b/src/basic/recurse-dir.c
|
|
@@ -56,7 +56,8 @@ int readdir_all(int dir_fd,
|
|
bs = MIN(MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries, buffer), (size_t) SSIZE_MAX);
|
|
assert(bs > de->buffer_size);
|
|
|
|
- n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
|
|
+ uint8_t *ptr = (uint8_t*) de->buffer + de->buffer_size;
|
|
+ n = getdents64(dir_fd, (struct dirent *)ptr, bs - de->buffer_size);
|
|
if (n < 0)
|
|
return -errno;
|
|
if (n == 0)
|
|
--
|
|
2.41.0
|
|
|