Explorar o código

Userland: Add missing checks for MappedFile.is_valid()

Ben Wiederhake %!s(int64=5) %!d(string=hai) anos
pai
achega
538a3a2579
Modificáronse 2 ficheiros con 6 adicións e 0 borrados
  1. 4 0
      Userland/disasm.cpp
  2. 2 0
      Userland/unzip.cpp

+ 4 - 0
Userland/disasm.cpp

@@ -37,6 +37,10 @@ int main(int argc, char** argv)
     }
 
     MappedFile file(argv[1]);
+    if (!file.is_valid()) {
+        // Already printed some error message.
+        return 1;
+    }
 
     X86::SimpleInstructionStream stream((const u8*)file.data(), file.size());
     X86::Disassembler disassembler(stream);

+ 2 - 0
Userland/unzip.cpp

@@ -183,6 +183,8 @@ int main(int argc, char** argv)
     }
 
     MappedFile mapped_file { zip_file_path };
+    if (!mapped_file.is_valid())
+        return 1;
 
     printf("Archive: %s\n", zip_file_path.characters());