From fff40f579fd464f78e2fc7f97f6e018cfbfe8406 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Wed, 17 May 2023 12:59:13 +0200 Subject: [PATCH] verify hash length on loading of file cache db --- MareSynchronos/FileCache/FileCacheManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MareSynchronos/FileCache/FileCacheManager.cs b/MareSynchronos/FileCache/FileCacheManager.cs index ec14e6b..4a8feac 100644 --- a/MareSynchronos/FileCache/FileCacheManager.cs +++ b/MareSynchronos/FileCache/FileCacheManager.cs @@ -60,13 +60,14 @@ public sealed class FileCacheManager : IDisposable try { var hash = splittedEntry[0]; + if (hash.Length != 40) throw new InvalidOperationException("Expected Hash length of 40, received " + hash.Length); var path = splittedEntry[1]; var time = splittedEntry[2]; AddHashedFile(ReplacePathPrefixes(new FileCacheEntity(hash, path, time))); } - catch (Exception) + catch (Exception ex) { - _logger.LogWarning("Failed to initialize entry {entry}, ignoring", entry); + _logger.LogWarning(ex, "Failed to initialize entry {entry}, ignoring", entry); } } }