Skip to content

Commit ae7e818

Browse files
committed
MIraMonRaster: fixing fuzzer Issue 443651667
A band name may be empty only if it is the only band present in the REL file. Otherwise, inferring the band name from the REL filename is considered an error. Consequently, for a REL file containing exactly one band, if the band name is empty, it shall be inferred from the REL filename. Example: REL: testI.rel --> IMG: test.img
1 parent eb62c2b commit ae7e818

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

frmts/miramon/miramon_band.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,33 @@ MMRBand::MMRBand(MMRRel &fRel, const CPLString &osBandSectionIn)
2727
m_osBandSection(osBandSectionIn)
2828

2929
{
30-
// Getting band and band file name from metadata
30+
// Getting band and band file name from metadata.
3131
if (!m_pfRel->GetMetadataValue(SECTION_ATTRIBUTE_DATA, osBandSectionIn,
3232
KEY_NomFitxer, m_osRawBandFileName) ||
3333
m_osRawBandFileName.empty())
3434
{
35-
m_osBandFileName =
36-
m_pfRel->MMRGetFileNameFromRelName(m_pfRel->GetRELName());
35+
// A band name may be empty only if it is the only band present
36+
// in the REL file. Otherwise, inferring the band name from the
37+
// REL filename is considered an error.
38+
// Consequently, for a REL file containing exactly one band, if
39+
// the band name is empty, it shall be inferred from the REL
40+
// filename.
41+
// Example: REL: testI.rel --> IMG: test.img
42+
if (m_pfRel->GetNBands() >= 1)
43+
m_osBandFileName = "";
44+
else
45+
{
46+
m_osBandFileName =
47+
m_pfRel->MMRGetFileNameFromRelName(m_pfRel->GetRELName());
48+
}
49+
3750
if (m_osBandFileName.empty())
3851
{
3952
m_nWidth = 0;
4053
m_nHeight = 0;
4154
CPLError(CE_Failure, CPLE_AssertionFailed,
4255
"The REL file '%s' contains a documented \
43-
band with no explicit name. Section [%s] or [%s:%s].",
56+
band with no explicit or wrong name. Section [%s] or [%s:%s].",
4457
m_pfRel->GetRELNameChar(), SECTION_ATTRIBUTE_DATA,
4558
SECTION_ATTRIBUTE_DATA, m_osBandSection.c_str());
4659
return;

0 commit comments

Comments
 (0)