Update of /cvsroot/audacity/audacity-src/src/import
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv22837
Modified Files:
ImportFLAC.cpp
Log Message:
Re-add check for FLAC header and add ID3 tag skipping to prevent crash.
Index: ImportFLAC.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/import/ImportFLAC.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- ImportFLAC.cpp 30 May 2009 15:15:02 -0000 1.36
+++ ImportFLAC.cpp 1 Jun 2009 15:42:50 -0000 1.37
@@ -40,6 +40,8 @@
#include "../Tags.h"
+#define FLAC_HEADER "fLaC"
+
#define DESC _("FLAC files")
static const wxChar *exts[] =
@@ -76,6 +78,12 @@
#include "../WaveTrack.h"
#include "ImportPlugin.h"
+#ifdef USE_LIBID3TAG
+extern "C" {
+#include <id3tag.h>
+}
+#endif
+
/* FLACPP_API_VERSION_CURRENT is 6 for libFLAC++ from flac-1.1.3 (see
<FLAC++/export.h>) */
#if !defined FLACPP_API_VERSION_CURRENT || FLACPP_API_VERSION_CURRENT < 6
#define LEGACY_FLAC
@@ -277,12 +285,29 @@
ImportFileHandle *FLACImportPlugin::Open(wxString filename)
{
// First check if it really is a FLAC file
-
+
+ int cnt;
wxFile binaryFile;
- if (!binaryFile.Open(filename))
+ if (!binaryFile.Open(filename)) {
return false; // File not found
+ }
+#ifdef USE_LIBID3TAG
+ // Skip any ID3 tags that might be present
+ id3_byte_t query[ID3_TAG_QUERYSIZE];
+ cnt = binaryFile.Read(query, sizeof(query));
+ cnt = id3_tag_query(query, cnt);
+ binaryFile.Seek(cnt);
+#endif
+
+ char buf[5];
+ cnt = binaryFile.Read(buf, 4);
binaryFile.Close();
+
+ if (cnt == wxInvalidOffset || strncmp(buf, FLAC_HEADER, 4) != 0) {
+ // File is not a FLAC file
+ return false;
+ }
// Open the file for import
FLACImportFileHandle *handle = new FLACImportFileHandle(filename);
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs