Skip to content

Commit 9e343bf

Browse files
committed
Corrected an overread in m04.luabnd.dcx
1 parent 170d74b commit 9e343bf

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

DeS-BNDBuild/DeS_BNDBuild.vb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ Public Class Des_BNDBuild
103103
Return UnicodeEncoding.GetString(b.ToArray())
104104
End Function
105105

106-
Private Function RAsciiStr(ByVal loc As UInteger) As String
106+
Private Function RAsciiStr(ByVal loc As UInteger, Optional ByVal num As UInteger = UInteger.MaxValue) As String
107107
Dim Str As String = ""
108108
Dim cont As Boolean = True
109109

110-
While cont
110+
While (cont And (loc < bytes.Length - 1) And (loc < num))
111111
If bytes(loc) > 0 Then
112112
Str = Str + Convert.ToChar(bytes(loc))
113113
loc += 1
@@ -580,7 +580,7 @@ Public Class Des_BNDBuild
580580
Dim OnlyDCX = False
581581

582582

583-
Select Case Microsoft.VisualBasic.Left(RAsciiStr(0), 4)
583+
Select Case RAsciiStr(0, 4)
584584
Case "BHD5"
585585

586586
'DS3 BHD5 Reversing by Atvaark
@@ -646,7 +646,7 @@ Public Class Des_BNDBuild
646646

647647
BinderID = ""
648648
If IsDS3 Then
649-
BinderID = RAsciiStrNumBytes(&H1C, RUInt32(&H18))
649+
BinderID = RAsciiStr(&H1C, RUInt32(&H18))
650650
Else
651651
For k = 0 To &HF
652652
Dim tmpchr As Char
@@ -718,9 +718,9 @@ Public Class Des_BNDBuild
718718

719719
Dim ms As New MemoryStream()
720720
Dim aes As New AesManaged() With {
721-
.Mode = CipherMode.ECB,
722-
.Padding = PaddingMode.None
723-
}
721+
.Mode = CipherMode.ECB,
722+
.Padding = PaddingMode.None
723+
}
724724

725725
Dim cs As New CryptoStream(ms, aes.CreateDecryptor(aesKey, iv), CryptoStreamMode.Write)
726726

@@ -755,9 +755,9 @@ Public Class Des_BNDBuild
755755

756756
Dim ms As New MemoryStream()
757757
Dim aes As New AesManaged() With {
758-
.Mode = CipherMode.ECB,
759-
.Padding = PaddingMode.None
760-
}
758+
.Mode = CipherMode.ECB,
759+
.Padding = PaddingMode.None
760+
}
761761

762762
Dim cs As New CryptoStream(ms, aes.CreateDecryptor(aesKey, iv), CryptoStreamMode.Write)
763763

@@ -1416,7 +1416,7 @@ Public Class Des_BNDBuild
14161416

14171417

14181418
Catch ex As Exception
1419-
MessageBox.Show(ex.Message)
1419+
'MessageBox.Show(ex.Message)
14201420
'MessageBox.Show("Stack Trace: " & vbCrLf & ex.StackTrace)
14211421
output(TimeOfDay & " - Unhandled exception - " & ex.Message & ex.StackTrace & Environment.NewLine)
14221422
End Try

0 commit comments

Comments
 (0)