File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ public class MSIFile implements Signable {
107
107
* @throws IOException if an I/O error occurs
108
108
*/
109
109
public static boolean isMSIFile (File file ) throws IOException {
110
+ if (file .length () < 8 ) {
111
+ return false ;
112
+ }
110
113
try (DataInputStream in = new DataInputStream (new FileInputStream (file ))) {
111
114
return in .readLong () == MSI_HEADER ;
112
115
}
Original file line number Diff line number Diff line change 18
18
19
19
import java .io .File ;
20
20
21
+ import org .apache .commons .io .FileUtils ;
21
22
import org .junit .Test ;
22
23
23
24
import static org .junit .Assert .*;
@@ -28,6 +29,11 @@ public class MSIFileTest {
28
29
public void testIsMSIFile () throws Exception {
29
30
assertFalse (MSIFile .isMSIFile (new File ("pom.xml" )));
30
31
assertTrue (MSIFile .isMSIFile (new File ("target/test-classes/minimal.msi" )));
32
+
33
+ // small file
34
+ File file = File .createTempFile ("small" , ".msi" );
35
+ FileUtils .writeByteArrayToFile (file , new byte [3 ]);
36
+ assertFalse (MSIFile .isMSIFile (file ));
31
37
}
32
38
33
39
@ Test
You can’t perform that action at this time.
0 commit comments