Browse Source

Added checks to see if paste file exists.

tags/3.0.0^2
Teknikode 8 months ago
parent
commit
063854f776

+ 5
- 0
Teknik/Areas/Paste/Controllers/PasteController.cs View File

@@ -106,6 +106,11 @@ namespace Teknik.Areas.Paste.Controllers
// Read in the file
string subDir = paste.FileName[0].ToString();
string filePath = Path.Combine(_config.PasteConfig.PasteDirectory, subDir, paste.FileName);
if (!System.IO.File.Exists(filePath))
{
return new StatusCodeResult(StatusCodes.Status404NotFound);
}

using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (AesCounterStream cs = new AesCounterStream(fs, false, keyBytes, ivBytes))
using (StreamReader sr = new StreamReader(cs, Encoding.Unicode))

+ 3
- 0
Teknik/Areas/Vault/Controllers/VaultController.cs View File

@@ -110,6 +110,9 @@ namespace Teknik.Areas.Vault.Controllers
// Read in the file
string subDir = paste.Paste.FileName[0].ToString();
string filePath = Path.Combine(_config.PasteConfig.PasteDirectory, subDir, paste.Paste.FileName);
if (!System.IO.File.Exists(filePath))
continue;

byte[] ivBytes = Encoding.Unicode.GetBytes(paste.Paste.IV);
byte[] keyBytes = AesCounterManaged.CreateKey(paste.Paste.Key, ivBytes, paste.Paste.KeySize);
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))

Loading…
Cancel
Save