mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added checks to see if paste file exists.
This commit is contained in:
parent
883318f871
commit
063854f776
@ -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))
|
||||
|
@ -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…
Reference in New Issue
Block a user