Skip to content

Commit

Permalink
fix parsing error with UTF-16 BOM
Browse files Browse the repository at this point in the history
array index out of bounds on some systems on parsed list
String.Trim don't remove BOM on .net 4
  • Loading branch information
b4tman committed Aug 12, 2021
1 parent 1c1ac2e commit 226c157
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion PasswordChanger1C/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void GetUsers()
}

var AuthStructure = ParserServices.ParsesClass.ParseString(Row["DATA"].ToString())[0];
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure[0]);
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure);
string PassHash = Hashes.Item1;
var G = new Guid((byte[])Row["ID"]);
Row.Add("UserGuidStr", G.ToString());
Expand Down
3 changes: 2 additions & 1 deletion PasswordChanger1C/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public class ParsesClass
{
public static ParserList ParseString(string Str)
{
var Arr = Str.Split(',');
char[] BomMarkers = { '\uFEFF' };
var Arr = Str.Trim(BomMarkers).Split(',');
int argPosition = 0;
var List = ParseStringInternal(Arr, ref argPosition, Arr.Length - 1);
return List;
Expand Down
6 changes: 3 additions & 3 deletions Tests/PasswordChanger1C_Tests/AccessFunctions_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void ReadInfoBase_TestPasswords(string filename)
continue; // skip default user
}
var AuthStructure = ParserServices.ParsesClass.ParseString(Row["DATA"].ToString())[0];
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure[0]);
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure);
string PassHash = Hashes.Item1.Trim('"');
string PassHash2 = Hashes.Item2.Trim('"');

Expand Down Expand Up @@ -76,7 +76,7 @@ public void WritePasswordIntoInfoBaseIB_Test(string original_filename)
var TableParams = AccessFunctions.ReadInfoBase(tmp_filename, "V8USERS");
var Row = TableParams.Records[1];
var AuthStructure = ParserServices.ParsesClass.ParseString(Row["DATA"].ToString())[0];
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure[0]);
var Hashes = CommonModule.GetPasswordHashTuple(AuthStructure);

var OldDataBinary = Row["DATA_BINARY"];
string OldData = Row["DATA"].ToString();
Expand All @@ -92,7 +92,7 @@ public void WritePasswordIntoInfoBaseIB_Test(string original_filename)
var TableParams_New = AccessFunctions.ReadInfoBase(tmp_filename, "V8USERS");
var Row_New = TableParams_New.Records[1];
var AuthStructure_New = ParserServices.ParsesClass.ParseString(Row_New["DATA"].ToString())[0];
var Hashes_New = CommonModule.GetPasswordHashTuple(AuthStructure_New[0]);
var Hashes_New = CommonModule.GetPasswordHashTuple(AuthStructure_New);
string PassHash_New = Hashes_New.Item1.Trim('"');
string PassHash2_New = Hashes_New.Item2.Trim('"');

Expand Down

1 comment on commit 226c157

@b4tman
Copy link
Owner Author

@b4tman b4tman commented on 226c157 Aug 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.