Commits

Qasim Khalil committed cb7ede0

Added error message when trying to mount a volume without specifying a file path. (Otherwise the KeePass window could lose focus for some reason.)

Comments (0)

Files changed (3)

src/KeepassTrueCryptMount/KeepassTrueCryptMountExt.cs

                 }
             }
 
+            var truecryptArgs = entry.ToTrueCryptArguments();
+            if (truecryptArgs.Equals(""))
+            {
+                //Some failure has occured
+                return;
+            }
+
             // do mount...
-            var truecryptProcessInfo = new ProcessStartInfo(this.pluginHost.GetTrueCryptExecutable(),entry.ToTrueCryptArguments());
+            var truecryptProcessInfo = new ProcessStartInfo(this.pluginHost.GetTrueCryptExecutable(), truecryptArgs);
 
             var truecryptProcess = Process.Start(truecryptProcessInfo);
             if(truecryptProcess != null)

src/KeepassTrueCryptMount/LanguageTexts.cs

         public const string TCMountMenuItemText = "Mount volume";
 
         public const string TCOptionsMenuItemText = "TrueCrypt Plugin Options";
+
+        public const string TCMountError = "TrueCrypt Mount Error";
+
+        public const string TCNoVolumeSpecifiedError = "No volume has been specified.";
     }
 }

src/KeepassTrueCryptMount/PwEntryExtension.cs

 {
     using System;
     using System.Text;
+    using System.Windows.Forms;
 
     using KeePassLib;
     using KeePass.Util;
                     volumeString = entry.Strings.GetSafe(EntryStrings.Volume).ReadString();
                 }
                 arguments.Append(" /v ");
+                if (volumeString.Equals(""))
+                {
+                    MessageBox.Show(LanguageTexts.TCNoVolumeSpecifiedError, LanguageTexts.TCMountError, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    return "";
+                }
                 if (volumeString.Contains(" ") && !volumeString.StartsWith("\"") && !volumeString.EndsWith("\""))
                 {
                     arguments.AppendFormat("\"{0}\"", volumeString);