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

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 1 11:04:23 PDT 2024


================
@@ -141,10 +141,24 @@ 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 fd = open("/dev/sda", O_WRONLY);
+  if (fd != -1)
+    return;
+  char data[512] = {};
+  while (write(fd, data, 512) != -1)
----------------
nickdesaulniers wrote:

done in 8081dd27cf49 (hmm...do I need to reopen the PR to have the change in my branch reflected in the PR?)

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


More information about the llvm-commits mailing list