mdgm wrote:What version of Firefox?
I have done some further testing myself and managed to find the cause of this and can now reproduce it 100% of the time without fail.
Basically if you read information about the file while it is still being written to (refresh the folder you are writing in / switch to that folder / have the file highlighted and the folder the current active window and sometimes Windows Explorer itself keeps updating as the file grows / the program tries to read that file while it's writing), the NAS running T6 corrupts it.
So in my case, what must have happened is I had explorer open in that folder (because I must have had it open to have double clicked to open it) while KeePass was trying to write to that file, explorer kept trying to read the file-size while KeePass was writing. That corrupted it.
I have made a program in C# to demonstrate the T6 flaw. This is the best way to cause the error and observe how it has corrupted the file (unless you have a good Internet connection and don't mind re-downloading lots of large files?). Understandably sending you my programs over the Internet is a bad idea (they could be viruses) so I attach my source code instead so that you can see what the code does and decide whether you trust it enough to run it on your computer.
The one thing I can't work out is why some byte patterns seem immune to this corruption but my program writes all of the possible bytes values to the file though and it reproduces the flaw every time (on only T6).
CentralHeating.txt (apologises for the RAIDiator testing pun) - Simply copy this into the free Microsoft Visual Studio Express (or one of the paid versions if you have it) as a C# Console application. You will need to change the path to a writeable place on your NAS where you want the file to be stored. The program when it runs creates a file with a repeated pattern of bytes. Then it reads back the same file and checks to see if it is still the same pattern. If the pattern is not the same as what it should have written, the program will tell you that the file is bad!
Now normally this will work perfectly ("SUCCESS - Program read back the file exactly as it should have been written."), HOWEVER, if you open up a Windows Explorer window and go to the folder on your NAS where the file is being written to and highlight it (Windows Explorer will keep updating the file size while it is being written to), maybe pressing or even holding F5 to refresh the folder a few times (just to be sure) as my program is running then the NAS will get distracted and corrupt the pattern in the file. Therefore rendering the file useless.
In a real world scenario this would mean if I was downloading a large binary file using Firefox and I had the file I was downloading to highlighted (or I kept pressing F5 or refresh in the folder where the file was being saved) as it was writing in Windows Explorer, my downloaded file would be corrupt (this doesn't seem to happen for all downloads though).
If you would prefer we can arrange a time for you to ring me and I can remotely show you this? and/or If you don't want to compile my program and would rather I sent you one you can just run and you have a computer you don't mind running my programs on (a test virtual machine or something?) then let me know and I will send you the .exe file for you to run.
When I go back to the T2 firmware, my program behaves normally even when I have left Windows Explorer open in the folder I am writing to and refresh it while the file in that folder is being written to. The bug is CLEARLY in T6 and I would guess has something to do with samba file locking. There is a page about Samba locking here (http://www.samba.org/samba/docs/man/Sam ... cking.html) which should help further diagnose why the connection gets broken by clients attempting to read files while another user is performing a write operation.
Hope this helps,
Matthew
P.s. On my NAS the configuration is "Disable full data journaling", "Disable journaling", "Enable fast CIFS writes" and the share ("/temp") allows Guest users to read/write (which is who I am logged in as) but the errors still occur even if I turn all these off and reboot the device.
using System;
using System.IO;
namespace CentralHeating
{
class Program
{
// Where the file should be written to. The file will be deleted if it already exists.
const string outputFile = @"\\192.168.1.3\temp\thrash\Radiator.key";
static void Main(string[] args)
{
// Write the program banner.
Console.WriteLine("----------------------------");
Console.WriteLine("Matthew1471! CentralHeating");
Console.WriteLine("----------------------------");
Console.WriteLine();
// Perform the "write of a binary file and then verify" test (deleting the file if it already exists).
writeThenVerifyFile();
Console.WriteLine("Program Completed. Press any key to exit.");
Console.ReadKey();
}
private static void writeThenVerifyFile()
{
// Trash the output file if it already exists.
if (File.Exists(outputFile)) { File.Delete(outputFile); }
// Whether there was a bad byte in the file.
bool badByte = false;
// Update the user.
Console.WriteLine("Starting Test..");
// The using statement in C# ensures the resources get cleaned up properly.
using (FileStream fileStream = new FileStream(outputFile, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite))
{
// We want to make a 25MB file.
for (int loopCount = 0; loopCount < 102400; loopCount++)
{
// Update the user on our progress.
if (loopCount % 10240 == 1) { Console.WriteLine("Writing " + (loopCount / 1024) + "%.."); }
// Write to the file all the bytes from 0x00 - 0xFF.
for (int count = 0; count < 256; count++) { fileStream.WriteByte((byte)count); }
}
}
// Open the file we have just written.
using (FileStream fileStream = new FileStream(outputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// We want to read the 25MB file.
for (int loopCount = 0; loopCount < 102400; loopCount++)
{
// Update the user on our progress.
if (loopCount % 10240 == 1) { Console.WriteLine("Reading " + (loopCount / 1024) + "%.."); }
// Read 256 bytes.
for (int count = 0; count < 256; count++)
{
// Read in a byte from the file.
byte readByte = (byte)fileStream.ReadByte();
// Check if the read byte matches the expected byte for this position in the file.
if (readByte != (byte)count)
{
// This now could be classed as a "corrupt" file.
badByte = true;
// Notify the user that a bad byte was encountered.
Console.WriteLine("ERROR - While reading the file, what should be 0x" + count.ToString("X2") + ", we instead found 0x" + readByte.ToString("X2") + ".");
}
}
}
}
Console.WriteLine();
// If there was not a bad byte in the file then the user will need a success message.
if (!badByte) { Console.WriteLine("SUCCESS - Program read back the file exactly as it should have been written."); }
Console.WriteLine();
}
}
}Return to Public RAIDiator Beta for ReadyNAS NV+/Duo/1100
Users browsing this forum: No registered users and 3 guests