Files
reiserfsprogs/configure.ac
T
lgcosta 293e6a7280
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
Fix real bugs and clean up the build with -Wall -Wextra
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

165 lines
4.6 KiB
Plaintext

dnl Process this file with autoconf to produce a configure script.
AC_INIT([reiserfsprogs], [3.6.25], [reiserfs-devel@vger.kernel.org])
AC_CANONICAL_HOST
AC_PREREQ([2.64])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_AUX_DIR([build-aux])
AH_TEMPLATE([HAVE_LIBUUID], [Define for enable libuuid using.])
AM_INIT_AUTOMAKE([1.11.1 foreign dist-xz silent-rules subdir-objects])
AM_SILENT_RULES([yes])
AM_MAINTAINER_MODE
dnl We install in /sbin, the utils are to be available on boot
dnl AC_PREFIX(/)
AC_CONFIG_HEADERS([include/config.h])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_AR
dnl libtool, replaces the long-obsolete AC_PROG_LIBTOOL
LT_INIT
dnl Checks for libraries.
# Check for LIBUUID
AC_CHECK_LIB([uuid], [uuid_generate], [], [AC_MSG_WARN([libuuid could not be found])])
UUID_LIBS="$LIBS"
AC_SUBST([UUID_LIBS])
AC_CHECK_LIB([com_err], [_et_list], [], [AC_MSG_ERROR([libcom_err could not be found])])
COM_ERR_LIBS="$LIBS"
AC_SUBST([COM_ERR_LIBS])
dnl Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h sys/ioctl.h unistd.h uuid/uuid.h])
AC_HEADER_MAJOR
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
dnl Use a deterministic language level: the code predates C99 and C23
dnl removes constructs (e.g. implicit int in some spots) it relies on.
AC_MSG_CHECKING([whether $CC accepts -std=gnu11])
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=gnu11"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no]); CFLAGS="$saved_CFLAGS"])
# Checking for compiler warning options
AC_CACHE_CHECK([whether -Wuninitialized works], [ac_cv_wuninitialized_flag], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[ac_cv_wuninitialized_flag=yes], [ac_cv_wuninitialized_flag=no])
])
AC_CACHE_CHECK([whether -Wno-unused-parameter works], [ac_cv_wno_unused_parameter_flag], [
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -Wno-unused-parameter"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[ac_cv_wno_unused_parameter_flag=yes], [ac_cv_wno_unused_parameter_flag=no])
CPPFLAGS="$saved_CPPFLAGS"
])
AC_CACHE_CHECK([whether -Wredundant-decls works], [ac_cv_wredundant_decls_flag], [
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -Wredundant-decls"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[ac_cv_wredundant_decls_flag=yes], [ac_cv_wredundant_decls_flag=no])
CPPFLAGS="$saved_CPPFLAGS"
])
# Check for large file
AC_SYS_LARGEFILE
if test -z "${ac_cv_sys_file_offset_bits}"; then
AC_MSG_WARN([Can't detect right _FILE_OFFSET_BITS. Will be forced to 64bit.])
ac_cv_sys_file_offset_bits=64
fi
AC_CHECK_SIZEOF([off_t], [8], [
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
])
AC_CHECK_SIZEOF([blkcnt_t], [8], [
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
])
dnl Checks for library functions.
AC_CHECK_FUNCS([strerror strstr strtol statfs getmntent hasmntopt memset time \
uname strptime ctime_r register_printf_modifier \
register_printf_specifier])
if test "x$ac_cv_func_register_printf_specifier" != xyes -a \
"x$ac_cv_func_register_printf_modifier" != xyes; then
AC_MSG_ERROR([reiserfsprogs requires a method to add printf modifiers])
fi
dnl -Wall -Wextra is clean as of this release; keep it opt-in so that
dnl distributions building with -Werror are not surprised by a future
dnl compiler adding a new diagnostic.
AC_ARG_ENABLE([warnings],
[AS_HELP_STRING([--enable-warnings], [build with -Wall -Wextra])])
if test "$enable_warnings" = "yes" ; then
CFLAGS="$CFLAGS -Wall -Wextra"
fi
dnl Never enable this. It is for debugging only
AC_ARG_ENABLE([io-failure-emulation],
[AS_HELP_STRING([--enable-io-failure-emulation], [Never use this. It is for debugging only])])
if test "$enable_io_failure_emulation" = "yes" ; then
AC_MSG_WARN([Careful! IO failure emulation is ON])
AC_DEFINE([IO_FAILURE_EMULATION], [1], [gets set when configure --enable-io-failure-emulation])
fi
if test "x$ac_cv_wno_unused_parameter_flag" = xyes; then
CFLAGS="$CFLAGS -Wno-unused-parameter"
fi
if test "x$ac_cv_wredundant_decls_flag" = xyes; then
CFLAGS="$CFLAGS -Wredundant-decls"
fi
if test "x$ac_cv_wuninitialized_flag" = xyes; then
CFLAGS="$CFLAGS -Wuninitialized"
fi
CPPFLAGS="-I\$(top_srcdir)/include $CPPFLAGS"
AC_CONFIG_FILES([
Makefile
include/Makefile
lib/Makefile
reiserfscore/Makefile
reiserfscore/reiserfscore.pc
fsck/Makefile
fsck/reiserfsck.8
mkreiserfs/Makefile
mkreiserfs/mkreiserfs.8
debugreiserfs/Makefile
debugreiserfs/debugreiserfs.8
resize_reiserfs/Makefile
resize_reiserfs/resize_reiserfs.8
tune/Makefile
tune/reiserfstune.8
])
AC_OUTPUT
AC_MSG_NOTICE([
Type 'make' to compile reiserfsprogs])