Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7914
Modified Files:
Tag: Audacity_UmixIt
Branding.cpp Envelope.cpp LabelTrack.cpp Project.cpp
Sequence.cpp Tags.cpp TimeTrack.cpp WaveTrack.cpp
Log Message:
Test XML input per NGS report for UmixIt.
Index: Envelope.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Envelope.cpp,v
retrieving revision 1.27.2.6
retrieving revision 1.27.2.6.2.1
diff -u -d -r1.27.2.6 -r1.27.2.6.2.1
--- Envelope.cpp 6 Nov 2006 04:50:10 -0000 1.27.2.6
+++ Envelope.cpp 17 Dec 2006 05:34:38 -0000 1.27.2.6.2.1
@@ -208,13 +208,21 @@
{
if (!strcmp(tag, "envelope")) {
int numPoints = 0;
+ long nValue;
while (*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
- if (!strcmp(attr, "numpoints"))
- numPoints = atoi(value);
+ if (!value)
+ break;
+ const wxString strValue = value;
+ if( !strcmp(attr, "numpoints") &&
+ XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&nValue))
+ numPoints = nValue;
}
+ if (nValue < 0)
+ return false;
+
WX_CLEAR_ARRAY(mEnv);
mEnv.Alloc(numPoints);
return true;
Index: Branding.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Attic/Branding.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- Branding.cpp 12 Dec 2006 03:27:08 -0000 1.1.2.2
+++ Branding.cpp 17 Dec 2006 05:34:38 -0000 1.1.2.3
@@ -20,7 +20,6 @@
{
m_strBrandName = "";
m_strBrandURL = "";
- m_BrandLogoFileName.Clear();
m_strBrandColorScheme = "";
}
@@ -33,26 +32,29 @@
const char *attr = *attrs++;
const char *value = *attrs++;
- if (!value) break;
+ if (!value)
+ break;
- if (!strcmp(attr, "brandname"))
+ if (!strcmp(attr, "brandname") && XMLValueChecker::IsGoodString(value))
m_strBrandName = value;
- else if (!strcmp(attr, "url"))
+ else if (!strcmp(attr, "url") && XMLValueChecker::IsGoodString(value))
m_strBrandURL = value;
else if (!strcmp(attr, "logofilename"))
{
// Logo file is supposed to be stored in the project data directory.
wxString strDirName =
GetActiveProject()->GetDirManager()->GetProjectDataDir();
- if (IsGoodFileNameFromXML(value, strDirName)) {
+ if (XMLValueChecker::IsGoodFileName(value, strDirName))
+ {
// Store full thing, not just file name, so don't need to add path
again.
m_BrandLogoFileName.Assign(strDirName, value);
m_BrandLogoFileName.Normalize(wxPATH_NORM_ABSOLUTE |
wxPATH_NORM_LONG);
- } else {
+ }
+ else
+ // Don't return failure. We'll just not have a logo to show.
wxMessageBox(wxString::Format(_("Could not open branding logo
file: %s"), value),
_("Error"), wxOK | wxICON_ERROR);
- }
}
- else if (!strcmp(attr, "colorscheme"))
+ else if (!strcmp(attr, "colorscheme") &&
XMLValueChecker::IsGoodString(value))
m_strBrandColorScheme = value;
} // while
Index: Tags.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Tags.cpp,v
retrieving revision 1.20.2.4
retrieving revision 1.20.2.4.2.1
diff -u -d -r1.20.2.4 -r1.20.2.4.2.1
--- Tags.cpp 28 Jun 2004 04:18:47 -0000 1.20.2.4
+++ Tags.cpp 17 Dec 2006 05:34:38 -0000 1.20.2.4.2.1
@@ -113,6 +113,7 @@
// loop through attrs, which is a null-terminated list of
// attribute-value pairs
+ long nValue;
while(*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
@@ -120,22 +121,23 @@
if (!value)
break;
- if (!strcmp(attr, "title"))
- mTitle = value;
- else if (!strcmp(attr, "artist"))
- mArtist = value;
- else if (!strcmp(attr, "album"))
- mAlbum = value;
- else if (!strcmp(attr, "track"))
- mTrackNum = atoi(value);
- else if (!strcmp(attr, "year"))
- mYear = value;
- else if (!strcmp(attr, "genre"))
- mGenre = atoi(value);
- else if (!strcmp(attr, "comments"))
- mComments = value;
- else if (!strcmp(attr, "id3v2"))
- mID3V2 = atoi(value);
+ const wxString strValue = value;
+ if (!strcmp(attr, "title") && XMLValueChecker::IsGoodString(strValue))
+ mTitle = strValue;
+ else if (!strcmp(attr, "artist") &&
XMLValueChecker::IsGoodString(strValue))
+ mArtist = strValue;
+ else if (!strcmp(attr, "album") &&
XMLValueChecker::IsGoodString(strValue))
+ mAlbum = strValue;
+ else if (!strcmp(attr, "track") && XMLValueChecker::IsGoodInt(strValue)
&& strValue.ToLong(&nValue))
+ mTrackNum = nValue;
+ else if (!strcmp(attr, "year") &&
XMLValueChecker::IsGoodString(strValue))
+ mYear = strValue;
+ else if (!strcmp(attr, "genre") && XMLValueChecker::IsGoodInt(strValue)
&& strValue.ToLong(&nValue))
+ mGenre = nValue;
+ else if (!strcmp(attr, "comments") &&
XMLValueChecker::IsGoodString(strValue))
+ mComments = strValue;
+ else if (!strcmp(attr, "id3v2") && XMLValueChecker::IsGoodInt(strValue)
&& strValue.ToLong(&nValue))
+ mID3V2 = (bool)nValue;
} // while
return true;
Index: LabelTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LabelTrack.cpp,v
retrieving revision 1.21.2.7
retrieving revision 1.21.2.7.2.1
diff -u -d -r1.21.2.7 -r1.21.2.7.2.1
--- LabelTrack.cpp 6 Nov 2006 04:50:10 -0000 1.21.2.7
+++ LabelTrack.cpp 17 Dec 2006 05:34:38 -0000 1.21.2.7.2.1
@@ -380,6 +380,7 @@
// loop through attrs, which is a null-terminated list of
// attribute-value pairs
bool has_t1 = false;
+ double dblValue;
while(*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
@@ -387,14 +388,22 @@
if (!value)
break;
- if (!strcmp(attr, "t"))
- Internat::CompatibleToDouble(wxString(value), &l->t);
- else if (!strcmp(attr, "t1")) {
+ const wxString strValue = value;
+ if (!XMLValueChecker::IsGoodString(strValue))
+ {
+ delete l;
+ return false;
+ }
+
+ if (!strcmp(attr, "t") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ l->t = dblValue;
+ else if (!strcmp(attr, "t1") &&
Internat::CompatibleToDouble(strValue, &dblValue))
+ {
has_t1 = true;
- Internat::CompatibleToDouble(wxString(value), &l->t1);
+ l->t1 = dblValue;
}
else if (!strcmp(attr, "title"))
- l->title = value;
+ l->title = strValue;
} // while
@@ -408,19 +417,21 @@
return true;
}
else if (!strcmp(tag, "labeltrack")) {
- if (*attrs) {
+ long nValue;
+ while (*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
if (!value)
return true;
- if (!strcmp(attr, "name"))
- mName = value;
- else if (!strcmp(attr, "numlabels")) {
- int len = atoi(value);
+ const wxString strValue = value;
+ if (!strcmp(attr, "name") && XMLValueChecker::IsGoodString(strValue))
+ mName = strValue;
+ else if (!strcmp(attr, "numlabels") &&
+ XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&nValue)) {
mLabels.Clear();
- mLabels.Alloc(len);
+ mLabels.Alloc(nValue);
}
}
Index: Sequence.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Sequence.cpp,v
retrieving revision 1.21.4.5.2.2
retrieving revision 1.21.4.5.2.3
diff -u -d -r1.21.4.5.2.2 -r1.21.4.5.2.3
--- Sequence.cpp 12 Dec 2006 03:27:11 -0000 1.21.4.5.2.2
+++ Sequence.cpp 17 Dec 2006 05:34:38 -0000 1.21.4.5.2.3
@@ -601,6 +601,8 @@
bool Sequence::HandleXMLTag(const char *tag, const char **attrs)
{
+ long nValue;
+
if (!strcmp(tag, "waveblock")) {
SeqBlock *wb = new SeqBlock();
wb->f = 0;
@@ -615,12 +617,20 @@
if (!value)
break;
+ // All these attributes have integer values, so just test & convert
here.
+ const wxString strValue = value;
+ if (!XMLValueChecker::IsGoodInt(strValue) ||
!strValue.ToLong(&nValue))
+ {
+ mErrorOpening = true;
+ return false;
+ }
+
if (!strcmp(attr, "start"))
- wb->start = atoi(value);
+ wb->start = nValue;
// Handle length tag from legacy project file
if (!strcmp(attr, "len"))
- mDirManager->SetLoadingBlockLength(atoi(value));
+ mDirManager->SetLoadingBlockLength(nValue);
} // while
@@ -638,26 +648,38 @@
if (!value)
break;
- if (!strcmp(attr, "maxsamples"))
+ // All these attributes have integer values, so just test & convert
here.
+ const wxString strValue = value;
+ if (!XMLValueChecker::IsGoodInt(strValue) ||
!strValue.ToLong(&nValue))
{
- // Security fixes per NGS report for UmixIt.
- // First, check that atoi probably won't overflow.
- if (strlen(value) > strlen("2147483647")) // MAXINT
- return false;
+ mErrorOpening = true;
+ return false;
+ }
+ if (!strcmp(attr, "maxsamples"))
+ {
// Dominic, 12/10/2006:
// Let's check that maxsamples is >= 1024
and <= 64 * 1024 * 1024
// - that's a pretty wide range of reasonable
values.
- sampleCount testMaxSamples = atoi(value);
- if ((testMaxSamples < 1024) || (testMaxSamples > 64 * 1024 * 1024))
+ if ((nValue < 1024) || (nValue > 64 * 1024 * 1024))
+ {
+ mErrorOpening = true;
return false;
- mMaxSamples = testMaxSamples;
+ }
+ mMaxSamples = nValue;
mDirManager->SetMaxSamples(mMaxSamples);
}
else if (!strcmp(attr, "sampleformat"))
- mSampleFormat = (sampleFormat)atoi(value);
+ mSampleFormat = (sampleFormat)nValue;
else if (!strcmp(attr, "numsamples"))
- mNumSamples = atoi(value);
+ {
+ if (nValue < 0)
+ {
+ mErrorOpening = true;
+ return false;
+ }
+ mNumSamples = nValue;
+ }
} // while
return true;
Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.178.2.17.2.6
retrieving revision 1.178.2.17.2.7
diff -u -d -r1.178.2.17.2.6 -r1.178.2.17.2.7
--- Project.cpp 12 Dec 2006 03:27:11 -0000 1.178.2.17.2.6
+++ Project.cpp 17 Dec 2006 05:34:38 -0000 1.178.2.17.2.7
@@ -167,13 +167,14 @@
bool ImportXMLTagHandler::HandleXMLTag(const char *tag, const char **attrs)
{
if (strcmp(tag, "import") ||
- attrs==NULL || (*attrs)==NULL ||
- strcmp(*attrs++, "filename")) return false;
+ attrs==NULL || (*attrs)==NULL ||
+ strcmp(*attrs++, "filename") || (*attrs)==NULL)
+ return false;
wxString strPathName = FILENAME(*attrs);
- if (!IsGoodPathNameFromXML(strPathName)) {
+ if (!XMLValueChecker::IsGoodPathName(strPathName)) {
// Maybe strPathName is just a fileName, not the full path. Try the
project data directory.
wxFileName fileName(mProject->GetDirManager()->GetProjectDataDir(),
strPathName);
- if (IsGoodFileNameFromXML(strPathName,
fileName.GetPath(wxPATH_GET_VOLUME))) {
+ if (XMLValueChecker::IsGoodFileName(strPathName,
fileName.GetPath(wxPATH_GET_VOLUME))) {
strPathName = fileName.GetFullPath();
} else {
wxMessageBox(_("Could not import file: ") + strPathName, _("Error"),
wxOK | wxICON_ERROR);
@@ -1947,6 +1948,7 @@
int requiredTags = 0;
wxString fileVersion = "";
wxString audacityVersion = "";
+ double dblValue;
// loop through attrs, which is a null-terminated list of
// attribute-value pairs
@@ -1957,21 +1959,25 @@
if (!value)
break;
+ const wxString strValue = value;
+ if (!XMLValueChecker::IsGoodString(strValue))
+ return false;
+
if (!strcmp(attr, "version")) {
- fileVersion = value;
+ fileVersion = strValue;
requiredTags++;
}
if (!strcmp(attr, "audacityversion")) {
- audacityVersion = value;
+ audacityVersion = strValue;
requiredTags++;
}
if (!strcmp(attr, "projname")) {
- wxString projName = value;
+ wxString projName = strValue;
wxString projPath = wxPathOnly(mFileName);
- if (!IsGoodSubdirNameFromXML(projName, projPath) ||
+ if (!XMLValueChecker::IsGoodSubdirName(projName, projPath) ||
!mDirManager->SetProject(projPath, projName, false)) {
wxMessageBox(wxString::Format(_("Couldn't find the project data
folder: \"%s\""),
@@ -1985,25 +1991,28 @@
requiredTags++;
}
- if (!strcmp(attr, "sel0"))
- Internat::CompatibleToDouble(wxString(value), &mViewInfo.sel0);
+ if (!strcmp(attr, "sel0") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ mViewInfo.sel0 = dblValue;
- if (!strcmp(attr, "sel1"))
- Internat::CompatibleToDouble(wxString(value), &mViewInfo.sel1);
+ if (!strcmp(attr, "sel1") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ mViewInfo.sel1 = dblValue;
- long longVpos;
if (!strcmp(attr, "vpos"))
- wxString(value).ToLong(&longVpos);
- mViewInfo.vpos = longVpos;
+ {
+ long longVpos;
+ if (XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&longVpos))
+ mViewInfo.vpos = longVpos;
+ }
- if (!strcmp(attr, "h"))
- Internat::CompatibleToDouble(wxString(value), &mViewInfo.h);
+ if (!strcmp(attr, "h") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ mViewInfo.h = dblValue;
- if (!strcmp(attr, "zoom"))
- Internat::CompatibleToDouble(wxString(value), &mViewInfo.zoom);
+ if (!strcmp(attr, "zoom") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ mViewInfo.zoom = dblValue;
- if (!strcmp(attr, "rate")) {
- Internat::CompatibleToDouble(wxString(value), &mRate);
+ if (!strcmp(attr, "rate") && Internat::CompatibleToDouble(strValue,
&dblValue))
+ {
+ mRate = dblValue;
mStatus->SetRate(mRate);
}
} // while
Index: WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.51.2.2
retrieving revision 1.51.2.2.2.1
diff -u -d -r1.51.2.2 -r1.51.2.2.2.1
--- WaveTrack.cpp 14 Nov 2004 11:59:03 -0000 1.51.2.2
+++ WaveTrack.cpp 17 Dec 2006 05:34:38 -0000 1.51.2.2.2.1
@@ -870,6 +870,8 @@
bool WaveTrack::HandleXMLTag(const char *tag, const char **attrs)
{
if (!strcmp(tag, "wavetrack")) {
+ double dblValue;
+ long nValue;
while(*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
@@ -877,29 +879,33 @@
if (!value)
break;
- if (!strcmp(attr, "rate"))
- Internat::CompatibleToDouble(wxString(value), &mRate);
- else if (!strcmp(attr, "offset")) {
- Internat::CompatibleToDouble(wxString(value), &mOffset);
+ const wxString strValue = value;
+ if (!strcmp(attr, "rate") &&
+ XMLValueChecker::IsGoodString(strValue) &&
Internat::CompatibleToDouble(strValue, &dblValue) &&
+ (dblValue >= 100.0) && (dblValue <= 100000.0)) // same bounds
as ImportRawDialog::OnOK
+ mRate = dblValue;
+ else if (!strcmp(attr, "offset") &&
+ XMLValueChecker::IsGoodString(strValue) &&
Internat::CompatibleToDouble(strValue, &dblValue))
+ {
+ mOffset = dblValue;
mEnvelope->SetOffset(mOffset);
}
- else if (!strcmp(attr, "gain")) {
- double d;
- Internat::CompatibleToDouble(wxString(value), &d);
- mGain = d;
- }
- else if (!strcmp(attr, "pan")) {
- double d;
- Internat::CompatibleToDouble(wxString(value), &d);
- if (d >= -1.0 && d <= 1.0)
- mPan = d;
- }
- else if (!strcmp(attr, "name"))
- mName = value;
- else if (!strcmp(attr, "channel"))
- mChannel = atoi(value);
- else if (!strcmp(attr, "linked"))
- mLinked = atoi(value);
+ else if (!strcmp(attr, "gain") &&
+ XMLValueChecker::IsGoodString(strValue) &&
Internat::CompatibleToDouble(strValue, &dblValue))
+ mGain = dblValue;
+ else if (!strcmp(attr, "pan") &&
+ XMLValueChecker::IsGoodString(strValue) &&
Internat::CompatibleToDouble(strValue, &dblValue) &&
+ (dblValue >= -1.0) && (dblValue <= 1.0))
+ mPan = dblValue;
+ else if (!strcmp(attr, "name") &&
XMLValueChecker::IsGoodString(strValue))
+ mName = strValue;
+ else if (!strcmp(attr, "channel") &&
+ XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&nValue) &&
+ (nValue >= LeftChannel) && (nValue <= MonoChannel))
+ mChannel = nValue;
+ else if (!strcmp(attr, "linked") &&
+ XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&nValue))
+ mLinked = (bool)nValue;
} // while
return true;
Index: TimeTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TimeTrack.cpp,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.1.4.1
diff -u -d -r1.8.2.1 -r1.8.2.1.4.1
--- TimeTrack.cpp 21 Apr 2004 23:33:26 -0000 1.8.2.1
+++ TimeTrack.cpp 17 Dec 2006 05:34:38 -0000 1.8.2.1.4.1
@@ -96,6 +96,8 @@
bool TimeTrack::HandleXMLTag(const char *tag, const char **attrs)
{
if (!strcmp(tag, "timetrack")) {
+ double dblValue;
+ long nValue;
while(*attrs) {
const char *attr = *attrs++;
const char *value = *attrs++;
@@ -103,13 +105,17 @@
if (!value)
break;
- else if (!strcmp(attr, "offset")) {
- Internat::CompatibleToDouble(wxString(value), &mOffset);
+ const wxString strValue = value;
+ if (!strcmp(attr, "offset") &&
+ XMLValueChecker::IsGoodString(strValue) &&
Internat::CompatibleToDouble(strValue, &dblValue))
+ {
+ mOffset = dblValue;
mEnvelope->SetOffset(mOffset);
- }else if (!strcmp(attr, "name"))
- mName = value;
- else if (!strcmp(attr, "channel"))
- mChannel = atoi(value);
+ }
+ else if (!strcmp(attr, "name") &&
XMLValueChecker::IsGoodString(strValue))
+ mName = strValue;
+ else if (!strcmp(attr, "channel") &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
+ mChannel = nValue;
} // while
return true;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs