Disallow DexFile::Open on directories
Change-Id: I003c883a586c12d243cb4fa3c0618ad4f239319f
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 31a7d10..381f7e0 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -107,6 +107,10 @@
close(fd);
return NULL;
}
+ if (S_ISDIR(sbuf.st_mode)) {
+ LOG(ERROR) << "attempt to mmap directory \"" << filename << "\"";
+ return NULL;
+ }
size_t length = sbuf.st_size;
UniquePtr<MemMap> map(MemMap::MapFile(length, PROT_READ, MAP_PRIVATE, fd, 0));
if (map.get() == NULL) {