Check if file is open before attempting to read tags: fix a crash

in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)

Reported by sebastia@, who found we were still affected by this bug
while he was working on a new port that uses taglib.

ok sebastia@
This commit is contained in:
dcoppa 2013-01-27 21:28:25 +00:00
parent 5f1b7ee832
commit 111534b400
14 changed files with 368 additions and 10 deletions

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.29 2013/01/23 14:30:40 dcoppa Exp $
# $OpenBSD: Makefile,v 1.30 2013/01/27 21:28:25 dcoppa Exp $
COMMENT= managing meta-data of audio formats
DISTNAME= taglib-1.8
REVISION= 4
REVISION= 5
CATEGORIES= audio devel
MASTER_SITES= https://github.com/downloads/taglib/taglib/

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_ape_apefile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/ape/apefile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/ape/apefile.cpp Sun Jan 27 19:52:41 2013
@@ -90,14 +90,16 @@ APE::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
APE::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : TagLib::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
APE::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_asf_asffile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/asf/asffile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/asf/asffile.cpp Sun Jan 27 19:52:41 2013
@@ -372,14 +372,16 @@ ASF::File::File(FileName file, bool readProperties, Pr
: TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
ASF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle propertiesStyle)
: TagLib::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
ASF::File::~File()

View File

@ -1,12 +1,46 @@
$OpenBSD: patch-taglib_flac_flacfile_cpp,v 1.1 2012/10/10 10:51:02 dcoppa Exp $
$OpenBSD: patch-taglib_flac_flacfile_cpp,v 1.2 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
Corrupted FLAC files scan can result in heavy CPU consumption: fix
it by considering a file as being invalid if a 0 length block is
found (upstream git commit ad9ffc62e6fac5c47f46eb96b39c614e32742eb5)
--- taglib/flac/flacfile.cpp.orig Wed Oct 10 12:21:53 2012
+++ taglib/flac/flacfile.cpp Wed Oct 10 12:22:25 2012
@@ -425,7 +425,7 @@ void FLAC::File::scan()
--- taglib/flac/flacfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/flac/flacfile.cpp Sun Jan 27 19:52:41 2013
@@ -108,7 +108,8 @@ FLAC::File::File(FileName file, bool readProperties,
TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory,
@@ -117,7 +118,8 @@ FLAC::File::File(FileName file, ID3v2::FrameFactory *f
{
d = new FilePrivate;
d->ID3v2FrameFactory = frameFactory;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
@@ -126,7 +128,8 @@ FLAC::File::File(IOStream *stream, ID3v2::FrameFactory
{
d = new FilePrivate;
d->ID3v2FrameFactory = frameFactory;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
FLAC::File::~File()
@@ -425,7 +428,7 @@ void FLAC::File::scan()
length = header.mid(1, 3).toUInt();
ByteVector data = readBlock(length);

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-taglib_it_itfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/it/itfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/it/itfile.cpp Sun Jan 27 19:52:41 2013
@@ -45,7 +45,8 @@ IT::File::File(FileName file, bool readProperties,
Mod::FileBase(file),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
IT::File::File(IOStream *stream, bool readProperties,
@@ -53,7 +54,8 @@ IT::File::File(IOStream *stream, bool readProperties,
Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
IT::File::~File()

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-taglib_mod_modfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/mod/modfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/mod/modfile.cpp Sun Jan 27 19:52:41 2013
@@ -45,7 +45,8 @@ Mod::File::File(FileName file, bool readProperties,
Mod::FileBase(file),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
Mod::File::File(IOStream *stream, bool readProperties,
@@ -53,7 +54,8 @@ Mod::File::File(IOStream *stream, bool readProperties,
Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
Mod::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_mp4_mp4file_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/mp4/mp4file.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/mp4/mp4file.cpp Sun Jan 27 19:52:41 2013
@@ -67,14 +67,16 @@ MP4::File::File(FileName file, bool readProperties, Au
: TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, audioPropertiesStyle);
+ if(isOpen())
+ read(readProperties, audioPropertiesStyle);
}
MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle audioPropertiesStyle)
: TagLib::File(stream)
{
d = new FilePrivate;
- read(readProperties, audioPropertiesStyle);
+ if(isOpen())
+ read(readProperties, audioPropertiesStyle);
}
MP4::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_mpc_mpcfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/mpc/mpcfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/mpc/mpcfile.cpp Sun Jan 27 19:52:41 2013
@@ -94,14 +94,16 @@ MPC::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
MPC::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : TagLib::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
MPC::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_ogg_flac_oggflacfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/ogg/flac/oggflacfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/ogg/flac/oggflacfile.cpp Sun Jan 27 19:52:41 2013
@@ -72,14 +72,16 @@ Ogg::FLAC::File::File(FileName file, bool readProperti
Properties::ReadStyle propertiesStyle) : Ogg::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Ogg::FLAC::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Ogg::FLAC::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_ogg_speex_speexfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/ogg/speex/speexfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/ogg/speex/speexfile.cpp Sun Jan 27 19:52:41 2013
@@ -62,14 +62,16 @@ Speex::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Speex::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Speex::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_ogg_vorbis_vorbisfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/ogg/vorbis/vorbisfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/ogg/vorbis/vorbisfile.cpp Sun Jan 27 19:52:41 2013
@@ -67,14 +67,16 @@ Vorbis::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Vorbis::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Ogg::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
Vorbis::File::~File()

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-taglib_s3m_s3mfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/s3m/s3mfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/s3m/s3mfile.cpp Sun Jan 27 19:52:41 2013
@@ -47,7 +47,8 @@ S3M::File::File(FileName file, bool readProperties,
Mod::FileBase(file),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
S3M::File::File(IOStream *stream, bool readProperties,
@@ -55,7 +56,8 @@ S3M::File::File(IOStream *stream, bool readProperties,
Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
S3M::File::~File()

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-taglib_wavpack_wavpackfile_cpp,v 1.1 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
--- taglib/wavpack/wavpackfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/wavpack/wavpackfile.cpp Sun Jan 27 19:52:41 2013
@@ -86,14 +86,16 @@ WavPack::File::File(FileName file, bool readProperties
Properties::ReadStyle propertiesStyle) : TagLib::File(file)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
WavPack::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : TagLib::File(stream)
{
d = new FilePrivate;
- read(readProperties, propertiesStyle);
+ if(isOpen())
+ read(readProperties, propertiesStyle);
}
WavPack::File::~File()

View File

@ -1,11 +1,35 @@
$OpenBSD: patch-taglib_xm_xmfile_cpp,v 1.1 2012/10/10 10:51:02 dcoppa Exp $
$OpenBSD: patch-taglib_xm_xmfile_cpp,v 1.2 2013/01/27 21:28:25 dcoppa Exp $
Check if file is open before attempting to read tags: fix a crash
in the file constructor if the file does not exist
(upstream git commit d15c8453ac75d9070008b9170ae114ea31a4b586)
Fix a crash when saving xm files
(upstream git commit 2d7414733eaa3263868c74abfa6cff38a8afe8d3)
--- taglib/xm/xmfile.cpp.orig Wed Oct 10 12:24:15 2012
+++ taglib/xm/xmfile.cpp Wed Oct 10 12:24:40 2012
@@ -443,7 +443,7 @@ bool XM::File::save()
--- taglib/xm/xmfile.cpp.orig Thu Sep 6 20:03:15 2012
+++ taglib/xm/xmfile.cpp Sun Jan 27 19:52:41 2013
@@ -359,7 +359,8 @@ XM::File::File(FileName file, bool readProperties,
Mod::FileBase(file),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
XM::File::File(IOStream *stream, bool readProperties,
@@ -367,7 +368,8 @@ XM::File::File(IOStream *stream, bool readProperties,
Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle))
{
- read(readProperties);
+ if(isOpen())
+ read(readProperties);
}
XM::File::~File()
@@ -443,7 +445,7 @@ bool XM::File::save()
return false;
uint len = std::min(22UL, instrumentHeaderSize - 4U);