public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Adolf Belka <adolf.belka@ipfire.org>
To: development@lists.ipfire.org
Cc: Adolf Belka <adolf.belka@ipfire.org>
Subject: [PATCH 1/2] lame: Update to version 4.0
Date: Tue, 15 Sep 2026 21:34:35 +0200	[thread overview]
Message-ID: <20260915193436.3130221-1-adolf.belka@ipfire.org> (raw)

- Update from version 3.100 to 4.0
- Update of rootfile
- 2 security fixes applied in 4.0
- Build bugs found in version 4.0 - fixes merged into what will become 4.1
- Upstream fixes patch from Linx From Scratch utilised
- lame-4.0 requires libmpg123 so patch for implemeting this also submitted
- Changelog
4.0
  Security
    Fixed a stack buffer overflow in the Blade-style encoder DLL (lame_enc.dll):
	beInitStream() copied a caller-supplied configuration structure using an
	unchecked, caller-controlled size, so an oversized or compiler-mismatched
	size could overwrite the stack. The size is now bounds-checked and the
	packed structure layout is consistent across MSVC and GCC/MinGW builds.
	[CVSS 8.4, Blade DLL]. Fix by Alexander Leidinger.
    Fixed an integer underflow in the AIFF header parser (parse_aiff_header()): a
	crafted file with a FORM chunk size below 4 wrapped the unsigned chunk-size
	counter to a huge value, sending the chunk-scanning loop into an effectively
	unbounded spin (a hang) on a tiny malicious input. The size is now validated
	before it is decremented. [CVSS 5.5, AIFF frontend]. Fix by Alexander Leidinger.
  Bug fixes
    Bump the major version to 4.0 (minor reset to 0). The LAME tag embedded in every
	encoded MP3 has a fixed 9-byte field for the encoder version string;
	since 3.100 the 3-digit minor version left no room for the trailing
	alpha/beta/release marker character, which was silently dropped.
    Fix building with recent GCC and Clang, which rejected the UTF-8 ID3 tag
	functions as an incompatible pointer type. Also fixes the corrupted genre
	written by --id3v2-utf8 --tg. Patch submitted by Rudi Heitbaum, patch ticket
	[ #102 ]; thanks to lazka for reporting, bug ticket [ #523 ].
    Export the UTF-8 ID3 tag functions id3tag_set_textinfo_utf8 and
	id3tag_set_comment_utf8 from the shared library, and fix a possible crash on
	out-of-memory in the ID3v2 user-defined tag setters, bug ticket [ #518 ].
3.101
    Patch submitted by KO Myung-Hun, patch ticket [ #80 ] OS/2 patches
    Patch submitted by Elio Blanca, patch ticket [ #82 ] Take advantage of terminal
	width on printing file names
    Bug fix for item [ #496 ] A critical bug in init_xrpow_core_sse
    Bug fix for item [ #500 ] Buffer overflow in encoder
    Bug fix for item [ #501 ] Encoder: Assertion 'eov->bitrate_index <=
	cfg->vbr_max_bitrate_index' failed during ABR encoding
    Bug fix for item [ #444 ] msacmdrv.h (structure packing alignment)
    Add faster CRC routine. The speed improvement is very small for typical use
	cases, but may be valuable if a lot of independent encodes are running and/or
	for a very long time. Patch by Robert Kausch of the fre:ac project.
    Fix configure script glob-ranges matching of compiler versions. This may result
	in faster code if no compiler optimization flags are specified during the
	configure step. This is part of patch ticket [ #491 ] lame 3.100 slower than
	3.99.5
    Disable Takehiros IEEE753 hack by default. On modern CPUs (anything more recent
	from AMD than hammer/k8; Intel: Core2, i3/5/7/9 and similar -- no idea about
	recent Atom/Pentium) it is a speed pessimization. Add a configure option for
	it so that it can be enabled on old CPUs.
    Update to more recent autotools based scripts, this may or may not fix issues
	during the configure stage for less popular or more recent OS or architectures.
    Use external libmpg123 instead of internal mpglib for mpeg decoding (unix-like
	systems which use the autotools ("configure; make; make install") build
	system). There are years of improvements in libmpg123 which we do not have in
	mpglib. Patch by Thomas Orgis of the mpg123 project.
    Update the Visual Studio project files to Visual Studio 2019. Patch by Michel Fink.
    Remove the macosx XCode project files, nobody stepped up to update them for the
	libmpg123 changes.
    Add ID3v2.4 support (UTF-8 ID3 tags). Patch by "kris".
    Add pkg-config support. Patch by Nicolas Boulenguez(Debian).
    Add IPv6 support for mp3rtp. This includes an incompatible change to the command
	line arguments for existing use cases / scripts. Patch by Surabhi.

Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 config/rootfiles/packages/lame            |   2 +-
 lfs/lame                                  |  16 +-
 src/patches/lame-4.0-upstream_fixes.patch | 178 ++++++++++++++++++++++
 3 files changed, 189 insertions(+), 7 deletions(-)
 create mode 100644 src/patches/lame-4.0-upstream_fixes.patch

diff --git a/config/rootfiles/packages/lame b/config/rootfiles/packages/lame
index dc3ae8b94..19d32e151 100644
--- a/config/rootfiles/packages/lame
+++ b/config/rootfiles/packages/lame
@@ -2,11 +2,11 @@ usr/bin/lame
 #usr/bin/mp3rtp
 #usr/include/lame
 #usr/include/lame/lame.h
-#usr/lib/libmp3lame.a
 #usr/lib/libmp3lame.la
 usr/lib/libmp3lame.so
 usr/lib/libmp3lame.so.0
 usr/lib/libmp3lame.so.0.0.0
+#usr/lib/pkgconfig/lame.pc
 #usr/share/doc/lame
 #usr/share/doc/lame/html
 #usr/share/doc/lame/html/about.html
diff --git a/lfs/lame b/lfs/lame
index 3b4f130a2..3edcb3ce7 100644
--- a/lfs/lame
+++ b/lfs/lame
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2026  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -26,7 +26,7 @@ include Config
 
 SUMMARY    = The LAME MP3 encoder
 
-VER        = 3.100
+VER        = 4.0
 
 THISAPP    = lame-$(VER)
 DL_FILE    = $(THISAPP).tar.gz
@@ -34,9 +34,9 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 PROG       = lame
-PAK_VER    = 2
+PAK_VER    = 3
 
-DEPS       =
+DEPS       = libmpg3
 
 SERVICES   =
 
@@ -48,7 +48,7 @@ objects = $(DL_FILE)
 
 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
 
-$(DL_FILE)_BLAKE2 = 6954d30cfd3951ea07762ba5dd7ff27038b78455f423099a225ebf748abddf9970e444456ca5a6179bd381e2205b32293392cb757c203901674860710fe2c183
+$(DL_FILE)_BLAKE2 = 9e05275c28bc6d086011362f211edc2e2cd831429ca4d2daa1bc0ae7084ebd9bec3c3db93e1cab638570a9f624468372b9ff39f3dc9e7d0b105dbba7f248b2df
 
 install : $(TARGET)
 
@@ -81,8 +81,12 @@ $(subst %,%_BLAKE2,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/lame-4.0-upstream_fixes.patch
 	$(UPDATE_AUTOMAKE)
-	cd $(DIR_APP) && ./configure --prefix=/usr --enable-mp3rtp
+	cd $(DIR_APP) && ./configure \
+				--prefix=/usr \
+				--enable-mp3rtp \
+				--disable-static
 	cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE)
 	cd $(DIR_APP) && make install
 	@rm -rf $(DIR_APP)
diff --git a/src/patches/lame-4.0-upstream_fixes.patch b/src/patches/lame-4.0-upstream_fixes.patch
new file mode 100644
index 000000000..f13fa5b72
--- /dev/null
+++ b/src/patches/lame-4.0-upstream_fixes.patch
@@ -0,0 +1,178 @@
+Submitted by:            Zeckma
+Date:                    2026-08-02
+Initial Package Version: 4.0
+Origin:                  Upstream
+Upstream Status:         Applied
+Description:             Fixes multiple build failures and fixes some settings.
+
+diff '--color=auto' -Naurp lame-4.0.orig/frontend/parse.c lame-4.0/frontend/parse.c
+--- lame-4.0.orig/frontend/parse.c	2023-12-18 06:34:05.000000000 -0700
++++ lame-4.0/frontend/parse.c	2026-08-02 08:57:33.475434331 -0600
+@@ -402,40 +402,44 @@ static int getIntValue(char const* token
+ }
+ 
+ #ifdef ID3TAGS_EXTENDED
++/* Set an ID3v2 tag field from UTF-16 data. The data pointer is genuinely
++   UTF-16 here, so the UTF-16 id3tag_* setters are used throughout. */
+ static int
+-set_id3v2tag(lame_global_flags* gfp, TextEncoding enc, int type, unsigned short const* str)
++set_id3v2tag_utf16(lame_global_flags* gfp, int type, unsigned short const* str)
+ {
+-    switch (enc)
++    switch (type)
+     {
+-        case TENC_UTF8:
+-            switch (type)
+-            {
+-                case 'a': return id3tag_set_textinfo_utf8(gfp, "TPE1", str);
+-                case 't': return id3tag_set_textinfo_utf8(gfp, "TIT2", str);
+-                case 'l': return id3tag_set_textinfo_utf8(gfp, "TALB", str);
+-                case 'g': return id3tag_set_textinfo_utf8(gfp, "TCON", str);
+-                case 'c': return id3tag_set_comment_ucs2(gfp, 0, 0, str);
+-                case 'n': return id3tag_set_textinfo_utf8(gfp, "TRCK", str);
+-                case 'y': return id3tag_set_textinfo_utf8(gfp, "TYER", str);
+-                case 'v': return id3tag_set_fieldvalue_ucs2(gfp, str);
+-            }
+-            ;;
+-        case TENC_UTF16:
+-            switch (type)
+-            {
+                 case 'a': return id3tag_set_textinfo_utf16(gfp, "TPE1", str);
+-                case 't': return id3tag_set_textinfo_utf16(gfp, "TIT2", str);
+-                case 'l': return id3tag_set_textinfo_utf16(gfp, "TALB", str);
+-                case 'g': return id3tag_set_textinfo_utf16(gfp, "TCON", str);
+-                case 'c': return id3tag_set_comment_utf16(gfp, 0, 0, str);
+-                case 'n': return id3tag_set_textinfo_utf16(gfp, "TRCK", str);
+-                case 'y': return id3tag_set_textinfo_utf16(gfp, "TYER", str);
+-                case 'v': return id3tag_set_fieldvalue_utf16(gfp, str);
+-            }
+-            ;;
+-        default:
+-            return -3;
++        case 't': return id3tag_set_textinfo_utf16(gfp, "TIT2", str);
++        case 'l': return id3tag_set_textinfo_utf16(gfp, "TALB", str);
++        case 'g': return id3tag_set_textinfo_utf16(gfp, "TCON", str);
++        case 'c': return id3tag_set_comment_utf16(gfp, 0, 0, str);
++        case 'n': return id3tag_set_textinfo_utf16(gfp, "TRCK", str);
++        case 'y': return id3tag_set_textinfo_utf16(gfp, "TYER", str);
++        case 'v': return id3tag_set_fieldvalue_utf16(gfp, str);
++    }
++    return -3;
++}
++
++/* Set an ID3v2 tag field from UTF-8 data. The data pointer is a UTF-8 char
++   string (not UTF-16 as the old, mistyped single handler assumed), so the
++   UTF-8 id3tag_* setters are used - including id3tag_set_fieldvalue_utf8 for
++   'v', which replaces the removed *_ucs2 calls the UTF-8 path used to make. */
++static int
++set_id3v2tag_utf8(lame_global_flags* gfp, int type, char const* str)
++{
++    switch (type)
++    {
++        case 'a': return id3tag_set_textinfo_utf8(gfp, "TPE1", str);
++        case 't': return id3tag_set_textinfo_utf8(gfp, "TIT2", str);
++        case 'l': return id3tag_set_textinfo_utf8(gfp, "TALB", str);
++        case 'g': return id3tag_set_textinfo_utf8(gfp, "TCON", str);
++        case 'c': return id3tag_set_comment_utf8(gfp, 0, 0, str);
++        case 'n': return id3tag_set_textinfo_utf8(gfp, "TRCK", str);
++        case 'y': return id3tag_set_textinfo_utf8(gfp, "TYER", str);
++        case 'v': return id3tag_set_fieldvalue_utf8(gfp, str);
+     }
++    return -3;
+ }
+ #endif
+ 
+@@ -480,8 +484,8 @@ id3_tag(lame_global_flags* gfp, int type
+         default:
+ #ifdef ID3TAGS_EXTENDED
+         case TENC_LATIN1: result = set_id3tag(gfp, type, x);   break;
+-        case TENC_UTF16:  result = set_id3v2tag(gfp, enc, type, x); break;
+-        case TENC_UTF8:   result = set_id3v2tag(gfp, enc, type, x); break;
++        case TENC_UTF16:  result = set_id3v2tag_utf16(gfp, type, x); break;
++        case TENC_UTF8:   result = set_id3v2tag_utf8(gfp, type, x); break;
+ #else
+         case TENC_RAW:    result = set_id3tag(gfp, type, x);   break;
+ #endif
+diff '--color=auto' -Naurp lame-4.0.orig/include/lame.def lame-4.0/include/lame.def
+--- lame-4.0.orig/include/lame.def	2023-12-15 03:39:54.000000000 -0700
++++ lame-4.0/include/lame.def	2026-08-02 09:03:31.295620002 -0600
+@@ -306,3 +306,6 @@ id3tag_set_textinfo_utf8	@2028
+ ; two external functions for ID3v2.4 tag support
+ id3tag_add_v2_4_UTF8 @2029
+ id3tag_v2_4_UTF8_only @2030
++
++; UTF-8 field-value setter (companion to id3tag_set_fieldvalue_utf16)
++id3tag_set_fieldvalue_utf8 @2031
+diff '--color=auto' -Naurp lame-4.0.orig/include/lame.h lame-4.0/include/lame.h
+--- lame-4.0.orig/include/lame.h	2026-07-11 01:30:24.000000000 -0600
++++ lame-4.0/include/lame.h	2026-08-02 08:56:37.227931107 -0600
+@@ -1297,6 +1297,9 @@ int CDECL id3tag_set_fieldvalue_ucs2(lam
+ int CDECL id3tag_set_fieldvalue_utf16(lame_t gfp, const unsigned short *fieldvalue);
+ 
+ /* experimental */
++int CDECL id3tag_set_fieldvalue_utf8(lame_t gfp, const char *fieldvalue);
++
++/* experimental */
+ int CDECL id3tag_set_textinfo_utf16(lame_t gfp, char const *id, unsigned short const *text);
+ 
+ /* experimental */
+diff '--color=auto' -Naurp lame-4.0.orig/include/libmp3lame.sym lame-4.0/include/libmp3lame.sym
+--- lame-4.0.orig/include/libmp3lame.sym	2026-07-11 01:34:32.000000000 -0600
++++ lame-4.0/include/libmp3lame.sym	2026-08-02 09:11:53.329373917 -0600
+@@ -193,6 +193,7 @@ hip_decode_headers
+ hip_decode1
+ hip_decode1_headers
+ hip_decode1_headersB
++hip_finish_pinfo
+ lame_decode_init
+ lame_decode
+ lame_decode_headers
+@@ -229,6 +230,7 @@ id3tag_set_textinfo_ucs2
+ id3tag_set_comment_ucs2
+ id3tag_set_fieldvalue_ucs2
+ id3tag_set_fieldvalue_utf16
++id3tag_set_fieldvalue_utf8
+ id3tag_set_textinfo_utf16
+ id3tag_set_comment_utf16
+ id3tag_set_textinfo_utf8
+diff '--color=auto' -Naurp lame-4.0.orig/libmp3lame/id3tag.c lame-4.0/libmp3lame/id3tag.c
+--- lame-4.0.orig/libmp3lame/id3tag.c	2026-07-11 01:34:32.000000000 -0600
++++ lame-4.0/libmp3lame/id3tag.c	2026-08-02 09:05:05.678553445 -0600
+@@ -1844,6 +1844,21 @@ id3tag_set_fieldvalue_ucs2(lame_t gfp, c
+     return id3tag_set_fieldvalue_utf16(gfp, fieldvalue);
+ }
+ 
++int
++id3tag_set_fieldvalue_utf8(lame_t gfp, const char *fieldvalue)
++{
++    if (is_lame_internal_flags_null(gfp)) {
++        return 0;
++    }
++    if (fieldvalue && *fieldvalue) {
++        if (strlen(fieldvalue) < 5 || fieldvalue[4] != '=') {
++            return -1;
++        }
++        return id3tag_set_textinfo_utf8(gfp, fieldvalue, &fieldvalue[5]);
++    }
++    return 0;
++}
++
+ size_t
+ lame_get_id3v2_tag(lame_t gfp, unsigned char *buffer, size_t size)
+ {
+diff '--color=auto' -Naurp lame-4.0.orig/libmp3lame/lame.c lame-4.0/libmp3lame/lame.c
+--- lame-4.0.orig/libmp3lame/lame.c	2020-05-06 01:45:56.000000000 -0600
++++ lame-4.0/libmp3lame/lame.c	2026-08-02 09:12:34.360869889 -0600
+@@ -1050,6 +1050,12 @@ lame_init_params(lame_global_flags * gfp
+             if (gfp->quality < 0)
+                 gfp->quality = LAME_DEFAULT_QUALITY;
+ 
++            /* VBR and ABR don't give good results with noise shaping
++             * settings used in quality levels below 4.
++             */
++            if (gfp->quality < 4)
++                gfp->quality = 4;
++
+ 
+             if (cfg->vbr == vbr_off)
+                 (void) lame_set_VBR_mean_bitrate_kbps(gfp, gfp->brate);
-- 
2.55.0



             reply	other threads:[~2026-09-15 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 19:34 Adolf Belka [this message]
2026-09-15 19:34 ` [PATCH 2/2] libmpg123: Install new package - 1.33.7 Adolf Belka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260915193436.3130221-1-adolf.belka@ipfire.org \
    --to=adolf.belka@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox