Skip to content

Commit f132074

Browse files
author
ChristianHaase
committed
fix: incorrect exception handling implementation
1 parent d7e17e3 commit f132074

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/ByteGuard.FileValidator/FileValidator.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,25 +1017,27 @@ public bool IsMalwareClean(string fileName, Stream stream)
10171017

10181018
stream.Seek(0, SeekOrigin.Begin);
10191019

1020+
bool isClean;
10201021
try
10211022
{
1022-
var isClean = _configuration.AntimalwareScanner.IsClean(stream, fileName);
1023-
if (!isClean)
1024-
{
1025-
if (_configuration.ThrowExceptionOnInvalidFile)
1026-
{
1027-
throw new MalwareDetectedException();
1028-
}
1029-
1030-
return false;
1031-
}
1032-
1033-
return true;
1023+
isClean = _configuration.AntimalwareScanner.IsClean(stream, fileName);
10341024
}
10351025
catch (Exception ex)
10361026
{
10371027
throw new AntimalwareScannerException(ex);
10381028
}
1029+
1030+
if (!isClean)
1031+
{
1032+
if (_configuration.ThrowExceptionOnInvalidFile)
1033+
{
1034+
throw new MalwareDetectedException();
1035+
}
1036+
1037+
return false;
1038+
}
1039+
1040+
return true;
10391041
}
10401042

10411043
/// <summary>

0 commit comments

Comments
 (0)