mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 10:04:24 +00:00
Prevent exception on non-standard CUE sheet (#22)
* Prevent exception on non-standard CUE sheet
In case of a CUE sheet with more than about 99 tracks, this `string`
constructor [1] threw an exception, because its repetition parameter
was negative.
Fixes Exception: 'count' must be non-negative.
* Update CDImage.cs
Shortened code by use of Math.Max()
[1] 980e63d956/CUETools.CDImage/CDImage.cs (L435)
This commit is contained in:
@@ -432,7 +432,8 @@ namespace CUETools.CDImage
|
||||
for (int iTrack = 1; iTrack < AudioTracks; iTrack++)
|
||||
mbSB.AppendFormat("{0:X8}", _tracks[_firstAudio + iTrack].Start - _tracks[_firstAudio].Start);
|
||||
mbSB.AppendFormat("{0:X8}", _tracks[_firstAudio + (int)AudioTracks - 1].End + 1 - _tracks[_firstAudio].Start);
|
||||
mbSB.Append(new string('0', (100 - (int)AudioTracks) * 8));
|
||||
// Use Math.Max() to avoid negative count number in case of non-standard CUE sheet with more than 99 tracks.
|
||||
mbSB.Append(new string('0', Math.Max(0, (100 - (int)AudioTracks) * 8)));
|
||||
byte[] hashBytes = (new SHA1CryptoServiceProvider()).ComputeHash(Encoding.ASCII.GetBytes(mbSB.ToString()));
|
||||
return Convert.ToBase64String(hashBytes).Replace('+', '.').Replace('/', '_').Replace('=', '-');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user