Skip to content

Commit

Permalink
Fix verification process proceeding if the file is not a valid ELF file
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jan 19, 2024
1 parent 411c419 commit 4890512
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions Refresher.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=hellscape/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=jvyden/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LITTLEBIGPLANETPS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=patchables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Reverify/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RFSH/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RPCS/@EntryIndexedValue">True</s:Boolean>
Expand Down
11 changes: 7 additions & 4 deletions Refresher/Patching/EbootPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,6 @@ public List<Message> Verify(string url, bool patchDigest)
List<Message> messages = new();

this.Stream.Position = 0;
Class output = ELFReader.CheckELFType(this.Stream);
if (output == Class.NotELF)
messages.Add(new Message(MessageLevel.Warning,
"File is not a valid ELF!"));

// Check url
if (url.EndsWith('/'))
Expand All @@ -309,6 +305,13 @@ public List<Message> Verify(string url, bool patchDigest)
//Try to create an absolute URI, if it fails, its not a valid URI
if (!Uri.TryCreate(url, UriKind.Absolute, out Uri? uri))
messages.Add(new Message(MessageLevel.Error, "URI is not valid"));

Class output = ELFReader.CheckELFType(this.Stream);
if (output == Class.NotELF)
{
messages.Add(new Message(MessageLevel.Error, "File is not a valid ELF file."));
return messages; // Early return, since here on out we check for valid patchables.
}

// If there are no Url or Host targets, we cant patch
// ReSharper disable once SimplifyLinqExpressionUseAll
Expand Down

0 comments on commit 4890512

Please sign in to comment.