Commit Graph
24 Commits
Author SHA1 Message Date
lgcosta 293e6a7280 Fix real bugs and clean up the build with -Wall -Wextra
build / build (clang, ) (push) Failing after 12s
build / build (gcc, ) (push) Failing after 9s
build / build (gcc, --enable-io-failure-emulation) (push) Failing after 8s
build / build (gcc, --enable-warnings) (push) Failing after 6s
Build: add --enable-warnings (-Wall -Wextra); the tree is now warning-free
with it, so distributions can opt in without risking a surprise -Werror
breakage from a future compiler.

Real bugs fixed (each verified by a reproducer):

- lib/io.c: open_rollback_file() read 28 bytes into char[28] with no NUL
  and then strcmp()'d it against a 28-character magic, reading one byte
  past the array. The condition was also inverted, so a *valid* rollback
  file was rejected -- but only sometimes: the missing NUL made the result
  depend on stack garbage (verified: -O0 rejects, -O2 accepts). The whole
  --save-rollback/--rollback-changes path was unreliable. Now the buffer is
  sized for the terminator, zeroed, and the comparison is `!= 0`.
  Verified end to end: save -> reopen -> restore reports "2 blocks
  restored, 0 skipped"; a random file is rejected.

- reiserfscore/reiserfslib.c, reiserfscore/journal.c: asprintf() was
  called with &fs->fs_file_name / &fs->fs_j_file_name, but those fields
  are `char *`, not `char **`. Passing a `char **` where `char *` is
  expected wrote through the wrong pointer -- silent memory corruption on
  any allocation. Fixed by using the new checked helper.

- reiserfscore/node_formats.c: `code < 0` on an unsigned parameter was
  dead code; the guard never fired.

- resize_reiserfs: missing `break` after -j made -j fall into -f, so
  "-j dev" silently also forced the operation. Sign-compare on the
  count_blocks() ternary and on count + blocks.

- lib/misc.c: strncat with bound == strlen(src) (equivalent to strcat) into
  char[256] from a char[256] dirent name -- up to 261 bytes. Replaced with
  snprintf plus an explicit fit check.

- lib/misc.c: die() used vsprintf into a fixed 1024-byte buffer.

- strncpy with bound == destination size (mkreiserfs, tune, progbar) never
  terminated; replaced with snprintf.

Allocator: drop the homegrown magic-header allocator. It wrote "_mem_begin_"
/ "mem_end" through strcpy inside the allocation, kept the size in an
`int`, and its only safety check (checkmem) was never called -- every call
site is commented out. Replaced with a size_t header that is over-aligned
via max_align_t, so malloc alignment guarantees still hold. expandmem()
now takes the old size from the header instead of a caller-supplied value
that could disagree with it.

Warnings: annotate the deliberate fallthroughs (fsck pass cascade, unit
suffix parsing, percentage parsing), fix the remaining sign-compare and
missing-field-initializer sites, and compute addresses of packed members
via char* + offsetof instead of &member.

Portability: asm/types.h -> linux/types.h, malloc.h and sys/vfs.h dropped
from includes.h (nothing used them), sys/vfs.h -> sys/statfs.h for
statfs(2).

Version: reiserfsprogs.spec said 3.6.23 while configure.ac said 3.6.25.

Remove the dead `#if 0` main() from hashes.c.

Add .github/workflows/build.yml: gcc, clang, --enable-warnings and
--enable-io-failure-emulation, each followed by a format/check/inspect
smoke test on a real image.

Verified: ./autogen.sh && ./configure --enable-warnings && make is clean
from scratch (0 warnings, 51 compile/link steps). mkreiserfs, reiserfsck
--check, debugreiserfs -S, reiserfstune -l and a real resize_reiserfs
128M -> 256M all succeed, and fsck reports the resized image clean.
2026-11-11 22:02:38 -03:00
Jeff Mahoney 3c0f2812b0 reiserfsprogs: use com_err in reiserfs_open
We dump failure messages to the terminal regardless of whether the caller
wants them or not.  This can be annoying when used as part of a general
tool that tests to see which file system is on a device by calling
its open routine.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2016-06-06 14:05:36 -04:00
Jeff Mahoney 6daa8a9c5a reiserfscore: constify struct pointer arguments
There are many cases where functions take pointers to keys, item heads,
paths, etc and don't modify them. Let's annotate them properly.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2014-03-13 17:42:58 -04:00
Jeff Mahoney 9b52a79ba2 reiserfscore: constify strings
There are many calls in which strings are passed as "char *" yet aren't
modified. This patch marks them const so callers can depend on it.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2014-03-13 17:42:57 -04:00
Jeff Mahoney 6bdb171b9e reiserfslib: add basic extended attribute helpers
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2014-03-11 16:39:52 -04:00
Jeff Mahoney e51777cf55 reiserfslib: add file data and directory iterators
This adds reiserfs_iterate_dir and reiserfs_iterate_file_data to
iterate over directories and file block/tail mapping.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2014-03-11 15:44:45 -04:00
Jeff Mahoney 1f65941572 mkreiserfs: move block_size_ok out of reiserfscore
block_size_ok is only used in mkreiserfs. We can pull it out of the
library.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2014-01-24 11:21:19 -05:00
Jeff Mahoney 97fa944851 reiserfsprogs: convert reiserfs_filsys_t from structure to pointer-to-structure
This makes it more consistent with e2fsprogs.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 19:02:20 -04:00
Jeff Mahoney 20357cf349 reiserfsprogs: Fix sparse "warning: Using plain integer as NULL pointer"
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 19:02:18 -04:00
Jeff Mahoney a1623ca6b3 reiserfscore: rename usearch_by_position to reiserfs_search_by_position
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 19:00:03 -04:00
Jeff Mahoney b94873771b reiserfscore: make reiserfs_open's filename argument const
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 19:00:03 -04:00
Jeff Mahoney 863ef57982 cleanup: remove dead code
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 17:17:38 -04:00
Jeff Mahoney 290bb8c378 cleanup: remove trailing whitespace
This patch just removes trailing whitespace.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 17:15:32 -04:00
Jeff Mahoney 47cff72748 cleanup: run indent with the Linux Kernel style across all code
Over the years, the reiserfs kernel code has been gradually cleaned up
to be more readable. This patch does the same to the progs code.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 17:14:42 -04:00
Jeff Mahoney b23d40f723 cleanup: rename common structure names
In order to convert reiserfscore into a externally-usable library,
we need to rename structures so they won't collide with other
namespaces.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 17:12:09 -04:00
Jeff Mahoney 149a82e2e9 Imported reiserfsprogs-3.6.21 2012-10-11 11:32:39 -04:00
Jeff Mahoney dac518d099 Imported reiserfsprogs-3.6.20 2012-10-11 11:32:09 -04:00
Jeff Mahoney 0ed773997f Imported reiserfsprogs-3.6.19 2012-10-11 11:31:31 -04:00
Jeff Mahoney 3078c83c48 Imported reiserfsprogs-3.6.18 2012-10-11 11:30:57 -04:00
Jeff Mahoney 18057cdad6 Imported reiserfsprogs-3.6.13 2012-10-11 11:30:27 -04:00
Jeff Mahoney cccefa4d84 Imported reiserfsprogs-3.6.9 2012-10-11 11:29:29 -04:00
Jeff Mahoney 99c89460c3 Imported reiserfsprogs-3.6.4 2012-10-11 11:28:37 -04:00
Jeff Mahoney b69459eb80 Imported reiserfsprogs-3.6.2 2012-10-11 11:27:42 -04:00
Jeff Mahoney e7102bdb66 Initial commit -- seeded with reiserfsprogs 3.x.0j 2012-10-11 11:26:22 -04:00