Skip to content

Commit 6adab7f

Browse files
committed
Block unexpected ISOs from splitting
1 parent 7277795 commit 6adab7f

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Program.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static void Main(string[] args)
5252
}
5353
}
5454

55+
/*
5556
for (int i = 0; i < XISO_LENGTH.Length; i++)
5657
{
5758
if (XISO_LENGTH[i] == isoSize)
@@ -61,6 +62,13 @@ static void Main(string[] args)
6162
break;
6263
}
6364
}
65+
*/
66+
67+
if (xgdType == null)
68+
{
69+
Console.WriteLine("Unexpected ISO size. Is this a valid redump ISO?");
70+
return;
71+
}
6472

6573
// Compare PVD against known PVDs to determine wave
6674
int? wave = null;
@@ -130,13 +138,20 @@ static void Main(string[] args)
130138
19 => 12,
131139
20 => 13,
132140
21 => 14,
133-
_ => 16,
141+
_ => -1,
134142
},
135143
5 => 14,
136144
6 => 15,
137-
7 or _ => 16,
145+
7 => 16,
146+
_ => -1,
138147
};
139148

149+
if (videoType == -1)
150+
{
151+
Console.WriteLine("Unexpected video partition. Cannot determine wave");
152+
return;
153+
}
154+
140155
long l0Length = VIDEO_L0_LENGTH[videoType];
141156
long l1Length = VIDEO_L1_LENGTH[videoType];
142157

@@ -183,9 +198,16 @@ static void Main(string[] args)
183198
0 => 0,
184199
1 or 2 or 3 or 4 => 1,
185200
5 => 2,
186-
6 or 7 or _ => 3,
201+
6 or 7 => 3,
202+
_ => -1,
187203
};
188204

205+
if (xisoType == -1)
206+
{
207+
Console.WriteLine("Unexpected ISO size. Is this a valid redump ISO?");
208+
return;
209+
}
210+
189211
isoFS.Seek(XISO_OFFSET[xisoType], SeekOrigin.Begin);
190212

191213
byte[] buf = new byte[1024 * 2048];

0 commit comments

Comments
 (0)