Commit Graph
16 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
lgcosta d3925f1521 Modernize the build system so it builds on current toolchains
The autotools setup could not bootstrap with modern autoconf/libtool:
`autoreconf -fi` failed with "possibly undefined macro: AC_PROG_LIBTOOL",
and several other macros used here were removed or deprecated long ago.

configure.ac:
  - AC_PROG_LIBTOOL -> LT_INIT (with AC_CONFIG_MACRO_DIRS/AC_CONFIG_AUX_DIR);
    add AM_PROG_AR required by newer libtool/automake.
  - AM_CONFIG_HEADER -> AC_CONFIG_HEADERS; AC_OUTPUT(files...) -> AC_OUTPUT
    with an explicit AC_CONFIG_FILES list.
  - AC_TRY_COMPILE -> AC_COMPILE_IFELSE; drop AC_HEADER_STDC,
    AC_PROG_GCC_TRADITIONAL, AC_STRUCT_ST_RDEV, AC_C_CONST and AC_C_INLINE
    (all obsolete or unconditionally available).
  - Drop AC_FUNC_MEMCMP/STRFTIME/VPRINTF; the corresponding HAVE_* macros
    were never referenced. Keep the register_printf_* check but test the
    ac_cv_func_* names that AC_CHECK_FUNCS actually sets.
  - Pin -std=gnu11 (the sources predate C99 and rely on implicit-int-era
    behaviour that newer C standards reject) and fix the -Wuninitialized
    probe, which never set its cache variable.
  - off_t/blkcnt_t sizeof fallbacks 64 -> 8 (bytes, not bits).

reiserfscore.pc.in: substitute @PACKAGE_VERSION@; REISERFSPROGS_VERSION was
never defined, so the generated .pc always carried an empty Version.

lib/parse_time.c: define _GNU_SOURCE, not _XOPEN_SOURCE. The valueless
_XOPEN_SOURCE disables _DEFAULT_SOURCE, which hides loff_t in <sys/types.h>
and broke the build. Every other translation unit already uses _GNU_SOURCE.

reiserfscore/xattr.c: drop the unused <sys/acl.h> include; no libacl symbol
is used (the reiserfs_acl_* structs come from reiserfs_fs.h), and the header
is not a declared build dependency.

Add autogen.sh to regenerate the build system after a fresh clone, and
update .gitignore for the build-aux/m4 layout and generated artifacts.

Verified: ./autogen.sh && ./configure && make completes on gcc 16 /
automake 1.18 / autoconf 2.72. mkreiserfs, reiserfsck --check,
debugreiserfs -S and reiserfstune all run against a freshly formatted
64 MiB image.
2026-11-11 21:29:42 -03:00
Jeff Mahoney 14b57362f7 build: libcom_err is required
configure is issuing a warning when libcom_err is missing but it should
fail instead.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2016-06-07 10:29:14 -04:00
Jeff Mahoney 1be2deaac0 Release 3.6.25. 2016-06-06 14:05:43 -04: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 19566d0878 build: introduce shared libreiserfscore.so and export it
In order to use reiserfs functionality in external programs, we need to
make a shared library and includes available.

This converts both libmisc and libreiserfscore into shared libraries, and
links libmisc into libreiserfscore. We also export the includes and
a pkg-config file.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 19:02:20 -04:00
Jeff Mahoney fe11487be9 Release 3.6.24. 2013-08-26 16:55:43 -04:00
Jeff Mahoney 98b84706a3 reiserfsprogs: autogenerate the version number in the man pages
The version string in the man pages was manually updated. Now it updates
when configure runs.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2013-08-26 16:35:40 -04:00
Jeff Mahoney b4582fed40 Release 3.6.23. 2013-07-01 15:05:13 -04:00
Mike Frysinger 90d328136c fix out of tree builds
This allows you to build out of tree like:
	mkdir build
	../configure
	make

This also fixes `make distcheck` since that uses the above mechanism.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:51:42 -04:00
Mike Frysinger ecb8f6ed3c clean up io-failure-emulation logic a bit
Use standard autoconf macros rather than open coding the logic.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:51:38 -04:00
Mike Frysinger 942e488bcd clean up compiler flag handling
ENABLE_DEBUG isn't used anywhere, so punt it.

--enable-debug is only used to control whether to enable -W flags by
default.  But there's no harm just always doing that, so drop the
configure flag and enable the -W flags when they're available.

AC_CACHE_CHECK requires cache vars have "_cv_" in their name, so tweak
all the cache var names to include that.

That leaves us with the PRESET_CFLAGS logic which is pointless nowadays
as autoconf largely does the same thing for us.  It'll default to using
'-O2 -g -Wall' if the compiler supports it, so no need to do it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:51:35 -04:00
Mike Frysinger 2537d91514 drop -fPIC usage
We don't create any libraries so there's no need to build with -fPIC.
Drop it all.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:51:21 -04:00
Mike Frysinger 0964757ec7 configure: update automake invocation
This converts away from the old/deprecated AM_INIT_AUTOMAKE method.

Also enable the nice silent build by default.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:50:55 -04:00
Mike Frysinger d0cf6adf13 fix version number
We're at 3.6.22 now, not 3.6.21.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:48:00 -04:00
Mike Frysinger da62161095 rename configure.in -> configure.ac
Newer autotools complains if you use the old style name.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2012-10-30 17:47:07 -04:00