Selaa lähdekoodia

FileTimeHelper.ReadNullableFileTime: throw InvalidDataException if FILETIME is negative

Tal Aloni 8 vuotta sitten
vanhempi
commit
bef9bd6e69
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      SMBLibrary/Helpers/FileTimeHelper.cs

+ 5 - 1
SMBLibrary/Helpers/FileTimeHelper.cs

@@ -52,10 +52,14 @@ namespace SMBLibrary
             {
                 return DateTime.FromFileTimeUtc(span);
             }
-            else
+            else if (span == 0)
             {
                 return null;
             }
+            else
+            {
+                throw new System.IO.InvalidDataException("FILETIME cannot be negative");
+            }
         }
 
         public static DateTime? ReadNullableFileTime(byte[] buffer, ref int offset)