public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: media-sound/easytag/files/, media-sound/easytag/
Date: Sun,  2 Dec 2018 18:43:54 +0000 (UTC)	[thread overview]
Message-ID: <1543776215.645351f868ac449b80ad507dd46ad0ccb1c3874e.asturm@gentoo> (raw)

commit:     645351f868ac449b80ad507dd46ad0ccb1c3874e
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  2 17:41:23 2018 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sun Dec  2 18:43:35 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=645351f8

media-sound/easytag: Fix ogg corruption

Non-maintainer commit. (Revert) Patch taken from openSUSE.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=776110
Reported-by: Florian Berger <florian.berger <AT> posteo.de>
Thanks-to: Patrice Levesque <gentoo.wayne <AT> ptaff.ca>
Closes: https://bugs.gentoo.org/617818
Package-Manager: Portage-2.3.52, Repoman-2.3.12
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 media-sound/easytag/easytag-2.4.3-r1.ebuild        |  72 ++++++
 .../files/easytag-2.4.3-ogg-corruption.patch       | 246 +++++++++++++++++++++
 2 files changed, 318 insertions(+)

diff --git a/media-sound/easytag/easytag-2.4.3-r1.ebuild b/media-sound/easytag/easytag-2.4.3-r1.ebuild
new file mode 100644
index 00000000000..30e559c81cd
--- /dev/null
+++ b/media-sound/easytag/easytag-2.4.3-r1.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+GNOME2_LA_PUNT="yes"
+inherit gnome2
+
+DESCRIPTION="GTK+ utility for editing MP2, MP3, MP4, FLAC, Ogg and other media tags"
+HOMEPAGE="https://wiki.gnome.org/Apps/EasyTAG"
+
+LICENSE="GPL-2 GPL-2+ LGPL-2 LGPL-2+ LGPL-2.1+"
+SLOT="0"
+KEYWORDS="alpha amd64 ~arm hppa ppc ppc64 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~x86-solaris"
+
+IUSE="flac mp3 mp4 opus speex test vorbis wavpack"
+REQUIRED_USE="
+	opus? ( vorbis )
+	speex? ( vorbis )
+"
+
+RDEPEND="
+	>=dev-libs/glib-2.38:2
+	media-libs/libcanberra[gtk3]
+	>=x11-libs/gtk+-3.10:3
+	flac? ( >=media-libs/flac-1.3 )
+	mp3? (
+		>=media-libs/id3lib-3.8.3-r8
+		>=media-libs/libid3tag-0.15.1b-r4
+	)
+	mp4? ( >=media-libs/taglib-1.9.1[mp4(+)] )
+	opus? (
+		>=media-libs/opus-1.1
+		>=media-libs/opusfile-0.4
+	)
+	speex? ( >=media-libs/speex-1.2_rc1 )
+	vorbis? (
+		>=media-libs/libogg-1.3.1
+		>=media-libs/libvorbis-1.3.4
+	)
+	wavpack? ( >=media-sound/wavpack-4.70 )
+"
+DEPEND="${RDEPEND}
+	app-text/docbook-xml-dtd:4.4
+	app-text/yelp-tools
+	dev-libs/libxml2
+	dev-libs/libxslt
+	>=dev-util/intltool-0.50
+	>=sys-devel/gettext-0.18.3.2
+	virtual/pkgconfig
+	test? (
+		dev-libs/appstream-glib
+		>=dev-util/desktop-file-utils-0.22
+	)
+"
+
+PATCHES=( "${FILESDIR}/${P}-ogg-corruption.patch" )
+
+src_configure() {
+	gnome2_src_configure \
+		--disable-Werror \
+		$(use_enable test appdata-validate) \
+		$(use_enable test tests) \
+		$(use_enable mp3) \
+		$(use_enable mp3 id3v23) \
+		$(use_enable vorbis ogg) \
+		$(use_enable opus) \
+		$(use_enable speex) \
+		$(use_enable flac) \
+		$(use_enable mp4) \
+		$(use_enable wavpack)
+}

diff --git a/media-sound/easytag/files/easytag-2.4.3-ogg-corruption.patch b/media-sound/easytag/files/easytag-2.4.3-ogg-corruption.patch
new file mode 100644
index 00000000000..7c4a9f619c3
--- /dev/null
+++ b/media-sound/easytag/files/easytag-2.4.3-ogg-corruption.patch
@@ -0,0 +1,246 @@
+From e5c640ca3f259f1b74e716723345521987a7bd68 Mon Sep 17 00:00:00 2001
+From: David King <amigadave@amigadave.com>
+Date: Wed, 9 Nov 2016 17:29:34 +0000
+Subject: Do not maintain an open handle on Ogg files
+
+Only keep a file open for reading long enough to read the necessary
+items from the file. Remove the file input stream from EtOggState, as
+it is no longer preserved across function calls.
+
+ src/tags/vcedit.c | 92 ++++++++++++++++++++++---------------------------------
+ 1 file changed, 36 insertions(+), 56 deletions(-)
+
+--- b/src/tags/vcedit.c
++++ a/src/tags/vcedit.c
+@@ -35,6 +35,7 @@
+ struct _EtOggState
+ {
+     /*< private >*/
++    GFileInputStream *in;
+ #ifdef ENABLE_SPEEX
+     SpeexHeader *si;
+ #endif
+@@ -125,6 +126,11 @@
+     }
+ #endif /* ENABLE_OPUS */
+ 
++    if (state->in)
++    {
++        g_object_unref (state->in);
++    }
++
+     memset (state, 0, sizeof (*state));
+ }
+ 
+@@ -239,7 +245,6 @@
+ 
+ static gboolean
+ _fetch_next_packet (EtOggState *s,
+-                    GInputStream *istream,
+                     ogg_packet *p,
+                     ogg_page *page,
+                     GError **error)
+@@ -269,8 +274,8 @@
+         while (ogg_sync_pageout (s->oy, page) <= 0)
+         {
+             buffer = ogg_sync_buffer (s->oy, CHUNKSIZE);
++            bytes = g_input_stream_read (G_INPUT_STREAM (s->in), buffer,
++                                         CHUNKSIZE, NULL, error);
+-            bytes = g_input_stream_read (istream, buffer, CHUNKSIZE, NULL,
+-                                         error);
+             ogg_sync_wrote (s->oy, bytes);
+ 
+             if(bytes == 0)
+@@ -303,7 +308,7 @@
+ 
+         g_assert (error == NULL || *error == NULL);
+         ogg_stream_pagein (s->os, page);
++        return _fetch_next_packet (s, p, page, error);
+-        return _fetch_next_packet (s, istream, p, page, error);
+     }
+ }
+ 
+@@ -402,13 +407,14 @@
+         return FALSE;
+     }
+ 
++    state->in = istream;
+     state->oy = g_slice_new (ogg_sync_state);
+     ogg_sync_init (state->oy);
+ 
+     while(1)
+     {
+         buffer = ogg_sync_buffer (state->oy, CHUNKSIZE);
++        bytes = g_input_stream_read (G_INPUT_STREAM (state->in), buffer,
+-        bytes = g_input_stream_read (G_INPUT_STREAM (istream), buffer,
+                                      CHUNKSIZE, NULL, error);
+         if (bytes == -1)
+         {
+@@ -648,7 +654,7 @@
+         }
+ 
+         buffer = ogg_sync_buffer (state->oy, CHUNKSIZE);
++        bytes = g_input_stream_read (G_INPUT_STREAM (state->in), buffer,
+-        bytes = g_input_stream_read (G_INPUT_STREAM (istream), buffer,
+                                      CHUNKSIZE, NULL, error);
+ 
+         if (bytes == -1)
+@@ -670,14 +676,11 @@
+ 
+     /* Headers are done! */
+     g_assert (error == NULL || *error == NULL);
+-    /* TODO: Handle error during stream close. */
+-    g_object_unref (istream);
+ 
+     return TRUE;
+ 
+ err:
+     g_assert (error == NULL || *error != NULL);
+-    g_object_unref (istream);
+     vcedit_clear_internals (state);
+     return FALSE;
+ }
+@@ -699,7 +702,6 @@
+     char *buffer;
+     int bytes;
+     int needflush = 0, needout = 0;
+-    GFileInputStream *istream;
+     GOutputStream *ostream;
+     gchar *buf;
+     gsize size;
+@@ -707,22 +709,11 @@
+ 
+     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ 
++    fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
++                                  G_FILE_QUERY_INFO_NONE, NULL, error);
+-    istream = g_file_read (file, NULL, error);
+-
+-    if (!istream)
+-    {
+-        g_assert (error == NULL || *error != NULL);
+-        return FALSE;
+-    }
+-
+-    fileinfo = g_file_input_stream_query_info (istream,
+-                                               G_FILE_ATTRIBUTE_STANDARD_SIZE,
+-                                               NULL, error);
+-
+     if (!fileinfo)
+     {
+         g_assert (error == NULL || *error != NULL);
+-        g_object_unref (istream);
+         return FALSE;
+     }
+ 
+@@ -783,8 +774,7 @@
+         }
+     }
+ 
++    while (_fetch_next_packet (state, &op, &ogin, error))
+-    while (_fetch_next_packet (state, G_INPUT_STREAM (istream), &op, &ogin,
+-                               error))
+     {
+         if (needflush)
+         {
+@@ -960,7 +950,7 @@
+     {
+         /* We copy the rest of the stream (other logical streams)
+          * through, a page at a time. */
++        while(1)
+-        while (1)
+         {
+             result = ogg_sync_pageout (state->oy, &ogout);
+ 
+@@ -999,7 +989,7 @@
+ 
+         buffer = ogg_sync_buffer (state->oy, CHUNKSIZE);
+ 
++        bytes = g_input_stream_read (G_INPUT_STREAM (state->in), buffer,
+-        bytes = g_input_stream_read (G_INPUT_STREAM (istream), buffer,
+                                      CHUNKSIZE, NULL, error);
+ 
+         if (bytes == -1)
+@@ -1017,19 +1007,11 @@
+         }
+     }
+ 
++
+ cleanup:
+     ogg_stream_clear (&streamout);
+     ogg_packet_clear (&header_comments);
+ 
+-    if (!g_input_stream_close (G_INPUT_STREAM (istream), NULL, error))
+-    {
+-        /* Ignore the _close() failure, and try the write anyway. */
+-        g_warning ("Error closing Ogg file for reading: %s",
+-                   (*error)->message);
+-        g_clear_error (error);
+-    }
+-
+-    g_object_unref (istream);
+     g_free (state->mainbuf);
+     g_free (state->bookbuf);
+     state->mainbuf = state->bookbuf = NULL;
+@@ -1063,13 +1045,41 @@
+     buf = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (ostream));
+     size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (ostream));
+ 
++    /* At least on Windows, writing to a file with an open-for-reading stream
++     * fails, so close the input stream before writing to the file. */
++    if (!g_input_stream_close (G_INPUT_STREAM (state->in), NULL, error))
++    {
++        /* Ignore the _close() failure, and try the write anyway. */
++        g_warning ("Error closing Ogg file for reading: %s",
++                   (*error)->message);
++        g_clear_error (error);
++    }
++
++    g_object_unref (state->in);
++    state->in = NULL;
++
+     /* Write the in-memory data back out to the original file. */
+     if (!g_file_replace_contents (file, buf, size, NULL, FALSE,
+                                   G_FILE_CREATE_NONE, NULL, NULL, error))
+     {
++        GError *tmp_error = NULL;
++
+         g_object_unref (ostream);
+         g_free (buf);
+ 
++        /* Re-open the file for reading, to keep the internal state
++         * consistent. */
++        state->in = g_file_read (file, NULL, &tmp_error);
++
++        if (!state->in)
++        {
++            g_warning ("Error opening Ogg file for reading after write failure: %s",
++                       tmp_error->message);
++            g_clear_error (&tmp_error);
++            g_assert (error == NULL || *error != NULL);
++            return FALSE;
++        }
++
+         g_assert (error == NULL || *error != NULL);
+         return FALSE;
+     }
+@@ -1077,6 +1087,16 @@
+     g_free (buf);
+     g_object_unref (ostream);
+ 
++    /* Re-open the file, now that the write has completed. */
++    state->in = g_file_read (file, NULL, error);
++
++    if (!state->in)
++    {
++        g_assert (error == NULL || *error != NULL);
++        return FALSE;
++    }
++
++
+     return TRUE;
+ }
+ 
+-- 
+cgit v0.12
+


             reply	other threads:[~2018-12-02 18:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-02 18:43 Andreas Sturmlechner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-12-02 18:43 [gentoo-commits] repo/gentoo:master commit in: media-sound/easytag/files/, media-sound/easytag/ Andreas Sturmlechner
2025-01-29 23:36 Andreas Sturmlechner
2025-01-30 16:18 Andreas Sturmlechner

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=1543776215.645351f868ac449b80ad507dd46ad0ccb1c3874e.asturm@gentoo \
    --to=asturm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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