diff options
| author | Michael Forney <mforney@mforney.org> | 2021-03-02 13:43:00 -0800 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2021-03-02 16:20:18 -0800 |
| commit | f412cdcf5e1edbf55d0de5c64bead37f7120c9c6 (patch) | |
| tree | d543ff565f3859aff3eeb0b4c388d965c92c584c /pkg/e2fsprogs/patch | |
| parent | f4d1d6a1596e6fdce7beb9091e03201fa3f69a92 (diff) | |
e2fsprogs: Update to 1.46.2
Diffstat (limited to 'pkg/e2fsprogs/patch')
4 files changed, 348 insertions, 0 deletions
diff --git a/pkg/e2fsprogs/patch/0001-libext2fs-avoid-pointer-arithmetic-on-void.patch b/pkg/e2fsprogs/patch/0001-libext2fs-avoid-pointer-arithmetic-on-void.patch new file mode 100644 index 00000000..ef067dcc --- /dev/null +++ b/pkg/e2fsprogs/patch/0001-libext2fs-avoid-pointer-arithmetic-on-void.patch @@ -0,0 +1,111 @@ +From c27416b8e150162d8a629dfb6c02c04081531a8b Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 2 Mar 2021 14:24:01 -0800 +Subject: [PATCH] libext2fs: avoid pointer arithmetic on `void *` + +The pointer operand to the + operator must be to a complete object +type. + +Signed-off-by: Michael Forney <mforney@mforney.org> +--- + e2fsck/recovery.c | 2 +- + lib/ext2fs/link.c | 20 +++++++++++--------- + lib/ext2fs/unix_io.c | 2 +- + 3 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c +index dc0694fc..889cd0e6 100644 +--- a/e2fsck/recovery.c ++++ b/e2fsck/recovery.c +@@ -179,7 +179,7 @@ static int jbd2_descriptor_block_csum_verify(journal_t *j, void *buf) + if (!jbd2_journal_has_csum_v2or3(j)) + return 1; + +- tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize - ++ tail = (struct jbd2_journal_block_tail *)((char *)buf + j->j_blocksize - + sizeof(struct jbd2_journal_block_tail)); + provided = tail->t_checksum; + tail->t_checksum = 0; +diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c +index a2c34ac5..80b16ac5 100644 +--- a/lib/ext2fs/link.c ++++ b/lib/ext2fs/link.c +@@ -110,7 +110,8 @@ static errcode_t dx_lookup(ext2_filsys fs, ext2_ino_t dir, + info->frames[0].buf); + if (errcode) + goto out_err; +- root = info->frames[0].buf + EXT2_DX_ROOT_OFF; ++ root = (struct ext2_dx_root_info *) ++ ((char *) info->frames[0].buf + EXT2_DX_ROOT_OFF); + hash_alg = root->hash_version; + if (hash_alg != EXT2_HASH_TEA && hash_alg != EXT2_HASH_HALF_MD4 && + hash_alg != EXT2_HASH_LEGACY) { +@@ -329,19 +330,19 @@ static errcode_t dx_move_dirents(ext2_filsys fs, struct dx_hash_map *map, + csum_size = sizeof(struct ext2_dir_entry_tail); + + for (i = 0; i < count; i++) { +- de = from + map[i].off; ++ de = (struct ext2_dir_entry *) ((char *) from + map[i].off); + rec_len = EXT2_DIR_REC_LEN(ext2fs_dirent_name_len(de)); + memcpy(to, de, rec_len); +- retval = ext2fs_set_rec_len(fs, rec_len, to); ++ retval = ext2fs_set_rec_len(fs, rec_len, (struct ext2_dir_entry *) to); + if (retval) + return retval; +- to += rec_len; ++ to = (char *)to + rec_len; + } + /* + * Update rec_len of the last dir entry to stretch to the end of block + */ +- to -= rec_len; +- rec_len = fs->blocksize - (to - base) - csum_size; ++ to = (char *)to - rec_len; ++ rec_len = fs->blocksize - ((char *) to - (char *) base) - csum_size; + retval = ext2fs_set_rec_len(fs, rec_len, to); + if (retval) + return retval; +@@ -396,7 +397,7 @@ static errcode_t dx_split_leaf(ext2_filsys fs, ext2_ino_t dir, + return retval; + } + for (offset = 0; offset < fs->blocksize; offset += rec_len) { +- de = buf + offset; ++ de = (struct ext2_dir_entry *) ((char *) buf + offset); + retval = ext2fs_get_rec_len(fs, de, &rec_len); + if (retval) + goto out; +@@ -501,7 +502,7 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir, + retval = ext2fs_set_rec_len(fs, fs->blocksize, de); + if (retval) + return retval; +- head = buf + 8; ++ head = (struct ext2_dx_countlimit *) ((char *) buf + 8); + count = ext2fs_le16_to_cpu(info->frames[i+1].head->count); + /* Growing tree depth? */ + if (i < 0) { +@@ -517,7 +518,8 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir, + /* Now update tree root */ + info->frames[0].head->count = ext2fs_cpu_to_le16(1); + info->frames[0].entries[0].block = ext2fs_cpu_to_le32(lblk); +- root = info->frames[0].buf + EXT2_DX_ROOT_OFF; ++ root = (struct ext2_dx_root_info *) ++ ((char *) info->frames[0].buf + EXT2_DX_ROOT_OFF); + root->indirect_levels++; + } else { + /* Splitting internal node in two */ +diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c +index 64eee342..6764a947 100644 +--- a/lib/ext2fs/unix_io.c ++++ b/lib/ext2fs/unix_io.c +@@ -315,7 +315,7 @@ bounce_read: + if (actual > align_size) + actual = align_size; + actual -= offset; +- memcpy(buf, data->bounce + offset, actual); ++ memcpy(buf, (char *) data->bounce + offset, actual); + + really_read += actual; + size -= actual; +-- +2.30.0 + diff --git a/pkg/e2fsprogs/patch/0002-libext2fs-use-offsetof-from-stddef.h.patch b/pkg/e2fsprogs/patch/0002-libext2fs-use-offsetof-from-stddef.h.patch new file mode 100644 index 00000000..98a69521 --- /dev/null +++ b/pkg/e2fsprogs/patch/0002-libext2fs-use-offsetof-from-stddef.h.patch @@ -0,0 +1,40 @@ +From 54cdf16b2e2f662635accdd2f1987068686ee553 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 2 Mar 2021 14:37:20 -0800 +Subject: [PATCH] libext2fs: use offsetof() from stddef.h + +offsetof is a standard C feature available from stddef.h, going +back all the way to ANSI C. + +Signed-off-by: Michael Forney <mforney@mforney.org> +--- + lib/ext2fs/compiler.h | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +diff --git a/lib/ext2fs/compiler.h b/lib/ext2fs/compiler.h +index 9aa9b4ec..49fe025e 100644 +--- a/lib/ext2fs/compiler.h ++++ b/lib/ext2fs/compiler.h +@@ -1,18 +1,7 @@ + #ifndef _EXT2FS_COMPILER_H + #define _EXT2FS_COMPILER_H + +-#ifndef __has_builtin +-#define __has_builtin(x) 0 +-#endif +- +-#undef offsetof +-#if __has_builtin(__builtin_offsetof) +-#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) +-#elif defined(__compiler_offsetof) +-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +-#else +-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +-#endif ++#include <stddef.h> + + #define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ +-- +2.30.0 + diff --git a/pkg/e2fsprogs/patch/0003-libext2fs-use-statement-expression-for-container_of-.patch b/pkg/e2fsprogs/patch/0003-libext2fs-use-statement-expression-for-container_of-.patch new file mode 100644 index 00000000..0061954f --- /dev/null +++ b/pkg/e2fsprogs/patch/0003-libext2fs-use-statement-expression-for-container_of-.patch @@ -0,0 +1,40 @@ +From ced6ce86e63fcbc7612253a60b6c87dfb173bd91 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 2 Mar 2021 14:42:53 -0800 +Subject: [PATCH] libext2fs: use statement-expression for container_of only on + GNU-compatible compilers + +Functionally, the statement-expression is not necessary here; it +just gives a bit of type-safety to make sure the pointer really +does have a compatible type with the specified member of the struct. + +When statement expressions are not available, we can just use a +portable fallback macro that skips this member type check. + +Signed-off-by: Michael Forney <mforney@mforney.org> +--- + lib/ext2fs/compiler.h | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lib/ext2fs/compiler.h b/lib/ext2fs/compiler.h +index 49fe025e..42faa61c 100644 +--- a/lib/ext2fs/compiler.h ++++ b/lib/ext2fs/compiler.h +@@ -3,9 +3,14 @@ + + #include <stddef.h> + ++#ifdef __GNUC__ + #define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) ++#else ++#define container_of(ptr, type, member) \ ++ ((type *)((char *)(ptr) - offsetof(type, member))) ++#endif + + + #endif /* _EXT2FS_COMPILER_H */ +-- +2.30.0 + diff --git a/pkg/e2fsprogs/patch/0004-libsupport-remove-unused-sort_r-definition.patch b/pkg/e2fsprogs/patch/0004-libsupport-remove-unused-sort_r-definition.patch new file mode 100644 index 00000000..c15dfe26 --- /dev/null +++ b/pkg/e2fsprogs/patch/0004-libsupport-remove-unused-sort_r-definition.patch @@ -0,0 +1,157 @@ +From 6a898554d5862f7cffbd674b0e1c690c6c8e83e4 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 2 Mar 2021 15:47:20 -0800 +Subject: [PATCH] libsupport: remove unused sort_r definition + +e2fsprogs uses sort_r_simple directly, so sort_r is not needed. + +On any linux (including linux-musl), sort_r is defined in terms of +qsort_r, so a compiler that does not support inlining may still +emit a reference to qsort_r. +--- + lib/support/sort_r.h | 120 ++----------------------------------------- + 1 file changed, 3 insertions(+), 117 deletions(-) + +diff --git a/lib/support/sort_r.h b/lib/support/sort_r.h +index dc17e8af..4c4ebf3b 100644 +--- a/lib/support/sort_r.h ++++ b/lib/support/sort_r.h +@@ -22,20 +22,11 @@ void sort_r(void *base, size_t nel, size_t width, + + */ + +-#define _SORT_R_INLINE inline +- +-#if (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \ +- defined __FreeBSD__ || defined __DragonFly__) +-# define _SORT_R_BSD +-#elif (defined _GNU_SOURCE || defined __gnu_hurd__ || defined __GNU__ || \ +- defined __linux__ || defined __MINGW32__ || defined __GLIBC__) +-# define _SORT_R_LINUX +-#elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__) +-# define _SORT_R_WINDOWS +-# undef _SORT_R_INLINE ++ ++#if (defined _WIN32 || defined _WIN64 || defined __WINDOWS__) + # define _SORT_R_INLINE __inline + #else +- /* Using our own recursive quicksort sort_r_simple() */ ++# define _SORT_R_INLINE inline + #endif + + #if (defined NESTED_QSORT && NESTED_QSORT == 0) +@@ -211,111 +202,6 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w, + } + } + +- +-#if defined NESTED_QSORT +- +- static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width, +- int (*compar)(const void *_a, +- const void *_b, +- void *aarg), +- void *arg) +- { +- int nested_cmp(const void *a, const void *b) +- { +- return compar(a, b, arg); +- } +- +- qsort(base, nel, width, nested_cmp); +- } +- +-#else /* !NESTED_QSORT */ +- +- /* Declare structs and functions */ +- +- #if defined _SORT_R_BSD +- +- /* Ensure qsort_r is defined */ +- extern void qsort_r(void *base, size_t nel, size_t width, void *thunk, +- int (*compar)(void *_thunk, +- const void *_a, const void *_b)); +- +- #endif +- +- #if defined _SORT_R_BSD || defined _SORT_R_WINDOWS +- +- /* BSD (qsort_r), Windows (qsort_s) require argument swap */ +- +- struct sort_r_data +- { +- void *arg; +- int (*compar)(const void *_a, const void *_b, void *_arg); +- }; +- +- static _SORT_R_INLINE int sort_r_arg_swap(void *s, +- const void *a, const void *b) +- { +- struct sort_r_data *ss = (struct sort_r_data*)s; +- return (ss->compar)(a, b, ss->arg); +- } +- +- #endif +- +- #if defined _SORT_R_LINUX +- +- typedef int(* __compar_d_fn_t)(const void *, const void *, void *); +- extern void qsort_r(void *base, size_t nel, size_t width, +- __compar_d_fn_t __compar, void *arg) +- __attribute__((nonnull (1, 4))); +- +- #endif +- +- /* implementation */ +- +- static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width, +- int (*compar)(const void *_a, +- const void *_b, void *_arg), +- void *arg) +- { +- #if defined _SORT_R_LINUX +- +- #if defined __GLIBC__ && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8)) +- +- /* no qsort_r in glibc before 2.8, need to use nested qsort */ +- sort_r_simple(base, nel, width, compar, arg); +- +- #else +- +- qsort_r(base, nel, width, compar, arg); +- +- #endif +- +- #elif defined _SORT_R_BSD +- +- struct sort_r_data tmp; +- tmp.arg = arg; +- tmp.compar = compar; +- qsort_r(base, nel, width, &tmp, sort_r_arg_swap); +- +- #elif defined _SORT_R_WINDOWS +- +- struct sort_r_data tmp; +- tmp.arg = arg; +- tmp.compar = compar; +- qsort_s(base, nel, width, sort_r_arg_swap, &tmp); +- +- #else +- +- /* Fall back to our own quicksort implementation */ +- sort_r_simple(base, nel, width, compar, arg); +- +- #endif +- } +- +-#endif /* !NESTED_QSORT */ +- + #undef _SORT_R_INLINE +-#undef _SORT_R_WINDOWS +-#undef _SORT_R_LINUX +-#undef _SORT_R_BSD + + #endif /* SORT_R_H_ */ +-- +2.30.0 + |
