From 304bf5b276bb1a8068d90c72026598c574a6844b Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 18 Apr 2024 23:56:32 +0300
Subject: [PATCH] mpg123-1.32.6
---
NEWS | 9 ++++++
configure | 55 +++++++++++++++++++++++++-------
configure.ac | 26 +++++++++++++--
mpg123.spec | 2 +-
src/config.h.in | 3 ++
src/genre.c | 3 ++
src/libmpg123/lfs_wrap.c | 23 ++++++++++++-
src/libmpg123/libmpg123.c | 17 ++++++++--
src/libmpg123/mpg123lib_intern.h | 3 --
src/libsyn123/resample.c | 2 ++
src/tests/plain_id3.c | 1 +
src/tests/resample_total.c | 2 ++
src/tests/seek_accuracy.c | 1 +
src/tests/seek_whence.c | 1 +
src/tests/sweeper.c | 1 +
src/tests/text.c | 1 +
src/tests/volume.c | 1 +
src/version.h | 2 +-
18 files changed, 130 insertions(+), 23 deletions(-)
diff --git a/NEWS b/NEWS
index 514a7b3..8fb377a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+1.32.6
+------
+- build: Detect forced 64 bit offsets on a dual-mode system that used
+ to default to 32 bits and drop ambiguous suffix-less symbols in that
+ case. This avoids subtle ABI breakage (causing memory corruption)
+ with existing binaries and instead has them fail during runtime linking.
+ You trigger that when having -D_FILE_OFFSET_BITS=64 in your compiler
+ flags during mpg123 build.
+
1.32.5
------
diff --git a/configure b/configure
index 15748ad..e504e8c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for mpg123 1.32.5.
+# Generated by GNU Autoconf 2.71 for mpg123 1.32.6.
#
# Report bugs to <maintainer@mpg123.org>.
#
@@ -621,8 +621,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='mpg123'
PACKAGE_TARNAME='mpg123'
-PACKAGE_VERSION='1.32.5'
-PACKAGE_STRING='mpg123 1.32.5'
+PACKAGE_VERSION='1.32.6'
+PACKAGE_STRING='mpg123 1.32.6'
PACKAGE_BUGREPORT='maintainer@mpg123.org'
PACKAGE_URL=''
@@ -1727,7 +1727,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures mpg123 1.32.5 to adapt to many kinds of systems.
+\`configure' configures mpg123 1.32.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1798,7 +1798,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of mpg123 1.32.5:";;
+ short | recursive ) echo "Configuration of mpg123 1.32.6:";;
esac
cat <<\_ACEOF
@@ -2076,7 +2076,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-mpg123 configure 1.32.5
+mpg123 configure 1.32.6
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2621,7 +2621,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by mpg123 $as_me 1.32.5, which was
+It was created by mpg123 $as_me 1.32.6, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@@ -3991,7 +3991,7 @@ fi
# Define the identity of the package.
PACKAGE='mpg123'
- VERSION='1.32.5'
+ VERSION='1.32.6'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -17440,8 +17440,19 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $switched_off_size" >&5
printf "%s\n" "$switched_off_size" >&6; }
-# If you have predefined _FILE_OFFSET_BITS, I will treat that as a system
-# property.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking unswitched off_t size" >&5
+printf %s "checking unswitched off_t size... " >&6; }
+if ac_fn_c_compute_int "$LINENO" "sizeof(off_t)" "unswitched_off_size" "
+#undef _FILE_OFFSET_BITS
+#include <sys/types.h>
+"
+then :
+
+fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $unswitched_off_size" >&5
+printf "%s\n" "$unswitched_off_size" >&6; }
+# Now the size without meddling, possibly enforced to 64 bits by system settings.
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
@@ -17501,6 +17512,18 @@ else
lfs_sensitive=no
fi
+forced_off_64=no
+if test "x$unswitched_off_size" != "x$ac_cv_sizeof_off_t"; then
+ if test "x$ac_cv_sizeof_off_t" = x8; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Detected system with enforced 64 bit offsets, dropping suffixless symbols for uncryptic ABI breakage." >&5
+printf "%s\n" "$as_me: Detected system with enforced 64 bit offsets, dropping suffixless symbols for uncryptic ABI breakage." >&6;}
+
+printf "%s\n" "#define FORCED_OFF_64 1" >>confdefs.h
+
+ forced_off_64=yes
+ fi
+fi
+
use_largefile=auto
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if native off_t is already 64 bits" >&5
@@ -22430,7 +22453,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by mpg123 $as_me 1.32.5, which was
+This file was extended by mpg123 $as_me 1.32.6, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -22498,7 +22521,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-mpg123 config.status 1.32.5
+mpg123 config.status 1.32.6
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
@@ -24229,8 +24252,16 @@ fi
echo " largefile sensitive ..... $lfs_sensitive"
echo " default offsets ......... $default_offset_bits"
echo " explicit 64 bit offsets . $use_largefile"
+echo " forced 64 bit offsets ... $forced_off_64"
echo " only portable API ....... $portable_api"
+if test "x$forced_off_64" = xyes; then
+ echo
+ echo "Note: Ensure that client programs are built with _FILE_OFFSET_BITS defined to 64, too."
+ echo " Old binaries built for 32 bit off_t may fail missing symbols in mpg123 libraries."
+ echo
+fi
+
echo "
Core libmpg123 features:
Layer I ................. $layer1
diff --git a/configure.ac b/configure.ac
index 234defc..173881e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1355,8 +1355,13 @@ AC_COMPUTE_INT(switched_off_size, sizeof(off_t), [
#include <sys/types.h>
])
AC_MSG_RESULT([$switched_off_size])
-# If you have predefined _FILE_OFFSET_BITS, I will treat that as a system
-# property.
+AC_MSG_CHECKING([unswitched off_t size])
+AC_COMPUTE_INT(unswitched_off_size, sizeof(off_t), [
+#undef _FILE_OFFSET_BITS
+#include <sys/types.h>
+])
+AC_MSG_RESULT([$unswitched_off_size])
+# Now the size without meddling, possibly enforced to 64 bits by system settings.
AC_CHECK_SIZEOF(off_t, [], [
#include <sys/types.h>
])
@@ -1381,6 +1386,15 @@ else
lfs_sensitive=no
fi
+forced_off_64=no
+if test "x$unswitched_off_size" != "x$ac_cv_sizeof_off_t"; then
+ if test "x$ac_cv_sizeof_off_t" = x8; then
+ AC_MSG_NOTICE([Detected system with enforced 64 bit offsets, dropping suffixless symbols for uncryptic ABI breakage.])
+ AC_DEFINE([FORCED_OFF_64], 1, [System setup enforces 64 bit offsets where 32 bit would be native.])
+ forced_off_64=yes
+ fi
+fi
+
use_largefile=auto
AC_MSG_CHECKING([if native off_t is already 64 bits])
@@ -2969,8 +2983,16 @@ fi
echo " largefile sensitive ..... $lfs_sensitive"
echo " default offsets ......... $default_offset_bits"
echo " explicit 64 bit offsets . $use_largefile"
+echo " forced 64 bit offsets ... $forced_off_64"
echo " only portable API ....... $portable_api"
+if test "x$forced_off_64" = xyes; then
+ echo
+ echo "Note: Ensure that client programs are built with _FILE_OFFSET_BITS defined to 64, too."
+ echo " Old binaries built for 32 bit off_t may fail missing symbols in mpg123 libraries."
+ echo
+fi
+
echo "
Core libmpg123 features:
Layer I ................. $layer1
diff --git a/mpg123.spec b/mpg123.spec
index ebb4e0e..90d1687 100644
--- a/mpg123.spec
+++ b/mpg123.spec
@@ -3,7 +3,7 @@
# - devel packages for alsa, sdl, etc... to build the respective output modules.
Summary: The fast console mpeg audio decoder/player.
Name: mpg123
-Version: 1.32.5
+Version: 1.32.6
Release: 1
URL: http://www.mpg123.org/
License: GPL
diff --git a/src/config.h.in b/src/config.h.in
index a95690b..ca148b1 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -37,6 +37,9 @@
/* Define if FIFO support is enabled. */
#undef FIFO
+/* System setup enforces 64 bit offsets where 32 bit would be native. */
+#undef FORCED_OFF_64
+
/* Define if frame index should be used. */
#undef FRAME_INDEX
diff --git a/src/genre.c b/src/genre.c
index f820d38..898081d 100644
--- a/src/genre.c
+++ b/src/genre.c
@@ -6,6 +6,9 @@
initially written by Shane Wegner
*/
+// Just to trigger recompilation on reconfigure (with differing --host).
+#include "config.h"
+
char *genre_table[] =
{
"Blues",
diff --git a/src/libmpg123/lfs_wrap.c b/src/libmpg123/lfs_wrap.c
index 9971422..c962a16 100644
--- a/src/libmpg123/lfs_wrap.c
+++ b/src/libmpg123/lfs_wrap.c
@@ -25,7 +25,7 @@
// Only activate the explicit largefile stuff here. The rest of the code shall
// work with abstract 64 bit offsets, or just plain default off_t (possibly
-// using _FILE_OFFSET_BYTES magic).
+// using _FILE_OFFSET_BITS magic).
// Note that this macro does not influence normal off_t-using code.
#ifdef LFS_LARGEFILE_64
#define _LARGEFILE64_SOURCE
@@ -208,10 +208,13 @@ static struct wrap_data* wrap_get(mpg123_handle *mh, int force_alloc)
/* After settling the data... start with some simple wrappers. */
// The fist block of wrappers is always present, using the native off_t width.
+// (Exception: If explicitly disabled using FORCED_OFF_64.)
// A second block mirrors that in case of sizeof(off_t)==4 with _32 suffix.
// A third block follows if 64 bit off_t is available with _64 suffix, just aliasing
// the int64_t functions.
+#ifndef FORCED_OFF_64
+
#define OFF_CONV(value, variable, handle) \
if((value) >= OFF_MIN && (value) <= OFF_MAX) \
variable = (off_t)(value); \
@@ -399,6 +402,8 @@ int attribute_align_arg mpg123_position( mpg123_handle *mh, off_t INT123_frame_o
return MPG123_OK;
}
+#endif // FORCED_OFF_64
+
// _32 aliases only for native 32 bit off_t
// Will compilers be smart enough to optimize away the extra function call?
#if SIZEOF_OFF_T == 4
@@ -523,6 +528,10 @@ int attribute_align_arg mpg123_position_32( mpg123_handle *mh, off_t INT123_fram
#define OFF64 off_t
#endif
+#ifndef FORCED_OFF_64
+// When 64 bit offsets are enforced, libmpg123.c defines the _64 functions directly.
+// There is no actual wrapper work, anyway.
+
int attribute_align_arg mpg123_open_64(mpg123_handle *mh, const char *path)
{
return mpg123_open(mh, path);
@@ -543,6 +552,8 @@ int attribute_align_arg mpg123_open_handle_64(mpg123_handle *mh, void *iohandle)
{
return mpg123_open_handle(mh, iohandle);
}
+#endif
+
int attribute_align_arg mpg123_framebyframe_decode_64(mpg123_handle *mh, OFF64 *num, unsigned char **audio, size_t *bytes)
{
@@ -860,6 +871,13 @@ static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count)
return read(fd, buf, count);
}
+// In forced 64 bit offset mode, the only definitions of these are
+// the _64 ones.
+#ifdef FORCED_OFF_64
+#define mpg123_replace_reader mpg123_replace_reader_64
+#define mpg123_replace_reader_handle mpg123_replace_reader_handle_64
+#endif
+
/* Reader replacement prepares the hidden handle storage for next mpg123_open_fd() or plain mpg123_open(). */
int attribute_align_arg mpg123_replace_reader(mpg123_handle *mh, mpg123_ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int) )
{
@@ -978,6 +996,8 @@ int attribute_align_arg mpg123_replace_reader_handle_64(mpg123_handle *mh, mpg12
#elif SIZEOF_OFF_T == 8
+// If 64 bit off_t is enforced, libmpg123.c already defines the _64 functions.
+#ifndef FORCED_OFF_64
int attribute_align_arg mpg123_replace_reader_64(mpg123_handle *mh, mpg123_ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int) )
{
return mpg123_replace_reader(mh, r_read, r_lseek);
@@ -987,5 +1007,6 @@ int attribute_align_arg mpg123_replace_reader_handle_64(mpg123_handle *mh, mpg12
{
return mpg123_replace_reader_handle(mh, r_read, r_lseek, cleanup);
}
+#endif
#endif
diff --git a/src/libmpg123/libmpg123.c b/src/libmpg123/libmpg123.c
index 6cbd29e..2a1c5ee 100644
--- a/src/libmpg123/libmpg123.c
+++ b/src/libmpg123/libmpg123.c
@@ -560,6 +560,15 @@ double attribute_align_arg mpg123_geteq2(mpg123_handle *mh, int channel, int ban
}
#ifndef PORTABLE_API
+
+#ifdef FORCED_OFF_64
+// Only _64 symbols for a system-wide enforced _FILE_OFFSET_BITS=64.
+#define mpg123_open mpg123_open_64
+#define mpg123_open_fixed mpg123_open_fixed_64
+#define mpg123_open_fd mpg123_open_fd_64
+#define mpg123_open_handle mpg123_open_handle_64
+#endif
+
/* plain file access, no http! */
int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
{
@@ -579,7 +588,9 @@ int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
// The convenience function mpg123_open_fixed() wraps over acual mpg123_open
// and hence needs to have the exact same code in lfs_wrap.c. The flesh is
// in INT123_open_fixed_pre() and INT123_open_fixed_post(), wich are only defined here.
-int INT123_open_fixed_pre(mpg123_handle *mh, int channels, int encoding)
+// Update: The open routines are just alias calls now, since the conversion to
+// int64_t internally.
+static int INT123_open_fixed_pre(mpg123_handle *mh, int channels, int encoding)
{
if(!mh)
return MPG123_BAD_HANDLE;
@@ -590,7 +601,7 @@ int INT123_open_fixed_pre(mpg123_handle *mh, int channels, int encoding)
return err;
}
-int INT123_open_fixed_post(mpg123_handle *mh, int channels, int encoding)
+static int INT123_open_fixed_post(mpg123_handle *mh, int channels, int encoding)
{
if(!mh)
return MPG123_BAD_HANDLE;
@@ -637,7 +648,7 @@ int attribute_align_arg mpg123_open_fd(mpg123_handle *mh, int fd)
ret = INT123_open_stream_handle(mh, mh->wrapperdata);
return ret;
}
-#endif
+#endif // PORTABLE_API
int attribute_align_arg mpg123_open_handle(mpg123_handle *mh, void *iohandle)
{
diff --git a/src/libmpg123/mpg123lib_intern.h b/src/libmpg123/mpg123lib_intern.h
index 2ca416d..b46c419 100644
--- a/src/libmpg123/mpg123lib_intern.h
+++ b/src/libmpg123/mpg123lib_intern.h
@@ -323,9 +323,6 @@ int64_t INT123_outblock_bytes(mpg123_handle *fr, int64_t s);
/* Postprocessing format conversion of freshly decoded buffer. */
void INT123_postprocess_buffer(mpg123_handle *fr);
-int INT123_open_fixed_pre(mpg123_handle *mh, int channels, int encoding);
-int INT123_open_fixed_post(mpg123_handle *mh, int channels, int encoding);
-
/* If networking is enabled and we really mean internal networking, the timeout_read function is available. */
#if defined (NETWORK) && !defined (WANT_WIN32_SOCKETS)
/* Does not work with win32 */
diff --git a/src/libsyn123/resample.c b/src/libsyn123/resample.c
index adee8a6..affe2a7 100644
--- a/src/libsyn123/resample.c
+++ b/src/libsyn123/resample.c
@@ -2038,8 +2038,10 @@ type attribute_align_arg name(long inrate, long outrate, type io) \
}
#if SIZEOF_OFF_T == 8
+#ifndef FORCED_OFF_64
resample_total_alias(off_t, syn123_resample_total, syn123_resample_total64)
resample_total_alias(off_t, syn123_resample_intotal, syn123_resample_intotal64)
+#endif
resample_total_alias(off_t, syn123_resample_total_64, syn123_resample_total64)
resample_total_alias(off_t, syn123_resample_intotal_64, syn123_resample_intotal64)
#elif SIZEOF_OFF_T == 4
diff --git a/src/tests/plain_id3.c b/src/tests/plain_id3.c
index e5fc64a..4d552cc 100644
--- a/src/tests/plain_id3.c
+++ b/src/tests/plain_id3.c
@@ -1,5 +1,6 @@
/* Just printing out ID3 tags with plain data from libmpg123 and explicitly called conversion routine. */
+#include "config.h"
#include "../compat/compat.h"
#include <mpg123.h>
#include "../common/debug.h"
diff --git a/src/tests/resample_total.c b/src/tests/resample_total.c
index ad18be2..fa54f74 100644
--- a/src/tests/resample_total.c
+++ b/src/tests/resample_total.c
@@ -3,10 +3,12 @@
//#define _FILE_OFFSET_BITS 64
//#define _FILE_OFFSET_BITS 32
#define SYN123_PORTABLE_API
+#include "config.h"
#include <syn123.h>
#include <inttypes.h>
+
#ifdef SYN123_PORTABLE_API
typedef int64_t synoff;
typedef int64_t synprint;
diff --git a/src/tests/seek_accuracy.c b/src/tests/seek_accuracy.c
index c0df12b..2470347 100644
--- a/src/tests/seek_accuracy.c
+++ b/src/tests/seek_accuracy.c
@@ -8,6 +8,7 @@
arguments: decoder preframes testfile.mpeg
*/
+#include "config.h"
#include <mpg123.h>
#include <stdio.h>
#include <fcntl.h>
diff --git a/src/tests/seek_whence.c b/src/tests/seek_whence.c
index 5f36d08..c061641 100644
--- a/src/tests/seek_whence.c
+++ b/src/tests/seek_whence.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include "../compat/compat.h"
#include <mpg123.h>
#include "../common/debug.h"
diff --git a/src/tests/sweeper.c b/src/tests/sweeper.c
index c324664..4041dc9 100644
--- a/src/tests/sweeper.c
+++ b/src/tests/sweeper.c
@@ -1,3 +1,4 @@
+#include "config.h"
#define SYN123_PORTABLE_API
#include <syn123.h>
#include <out123.h>
diff --git a/src/tests/text.c b/src/tests/text.c
index 23c136b..f638108 100644
--- a/src/tests/text.c
+++ b/src/tests/text.c
@@ -8,6 +8,7 @@
arguments: decoder testfile.mpeg
*/
+#include "config.h"
#include <mpg123.h>
#include "../compat/compat.h"
diff --git a/src/tests/volume.c b/src/tests/volume.c
index 1456ab7..b80c0e1 100644
--- a/src/tests/volume.c
+++ b/src/tests/volume.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include "syn123.h"
#include <math.h>
#include <stdio.h>
diff --git a/src/version.h b/src/version.h
index 9a8d09f..2818ca9 100644
--- a/src/version.h
+++ b/src/version.h
@@ -16,7 +16,7 @@
// only single spaces as separator to ease parsing by build scripts
#define MPG123_MAJOR 1
#define MPG123_MINOR 32
-#define MPG123_PATCH 5
+#define MPG123_PATCH 6
// Don't get too wild with that to avoid confusing m4. No brackets.
// Also, it should fit well into a sane file name for the tarball.
#define MPG123_SUFFIX ""