bashedev / win-sshfs

Automatically exported from code.google.com/p/win-sshfs
1 stars 0 forks source link

an corrupted config.xml can cuase win-sshfs crash #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.lauch win-sshfs
2.an exception dialog appear
3.I suspect corrupted config.xml(power lost cause the config.xml crash?) lead 
this

What is the expected output? What do you see instead?

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Xml.XmlException: Unexpected end of file.
   at System.Xml.EncodingStreamWrapper.ReadBOMEncoding(Boolean notOutOfBand)
   at System.Xml.EncodingStreamWrapper..ctor(Stream stream, Encoding encoding)
   at System.Xml.XmlUTF8TextReader.SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
   at Sshfs.Utilities.Load[T](List`1 list, String file)
   at Sshfs.MainForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam

What version of the product are you using?

win-sshfs:
Client OS: win7 64 bit
Server OS:
Ssh server:

Please provide any additional information below.

following code can work around this:

$ git diff
diff --git a/Sshfs/Sshfs/Utilities.cs b/Sshfs/Sshfs/Utilities.cs
index f57eac0..9e582e8 100644
--- a/Sshfs/Sshfs/Utilities.cs
+++ b/Sshfs/Sshfs/Utilities.cs
@@ -31,9 +31,16 @@ namespace Sshfs
                 var stream = _userStoreForAssembly.OpenFile(file, FileMode.Open
                                                             FileAccess.Read))
             {
-                list.Clear();
-
-                list.AddRange(xmlSerializer.ReadObject(stream) as IEnumerable<T
+                try
+                {
+                    list.Clear();
+
+                    list.AddRange(xmlSerializer.ReadObject(stream) as IEnumerab
+                }
+                catch
+                {
+                    _userStoreForAssembly.DeleteFile(file);
+                }
             }
         }

Original issue reported on code.google.com by zhubi...@gmail.com on 20 Jan 2013 at 11:14