[Bug sanitizer/87191] UBSan doesn't catch invalid pointer arithmetic outside known object bounds

2022-10-06 Thread Dmitriy.Poterukha at uvoteam dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87191

--- Comment #6 from creeon  ---
#0 0x401191 in bar (/home/marxin/Programming/testcases/a.out+0x401191)
#1 0x40122a in main https://stemhave.com/programming-help.html
(/home/marxin/Programming/testcases/a.out+0x40122a)
#2 0x76c71fea in __libc_start_main ../csu/libc-start.c:308
#3 0x4010a9 in _start (/home/marxin/Programming/testcases/a.out+0x4010a9)

At a minimum we should diagnose if offsetting a pointer to a toplevel object
not by 0/1 (ideally also if not by 0 and then dereferencing?), e.g.:

warning: creating out-of-bounds pointer based on complete object 'a'

How i canl all fix it?

[Bug sanitizer/87191] UBSan doesn't catch invalid pointer arithmetic outside known object bounds

2022-10-06 Thread Dmitriy.Poterukha at uvoteam dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87191

creeon  changed:

   What|Removed |Added

 CC||Dmitriy.Poterukha at uvoteam 
dot c
   ||om

--- Comment #5 from creeon  ---
#0 0x401191 in bar (/home/marxin/Programming/testcases/a.out+0x401191)
#1 0x40122a in main https://stemhave.com/programming-help.html
(/home/marxin/Programming/testcases/a.out+0x40122a)
#2 0x76c71fea in __libc_start_main ../csu/libc-start.c:308
#3 0x4010a9 in _start (/home/marxin/Programming/testcases/a.out+0x4010a9)

At a minimum we should diagnose if offsetting a pointer to a toplevel object
not by 0/1 (ideally also if not by 0 and then dereferencing?), e.g.:

warning: creating out-of-bounds pointer based on complete object 'a'

[Bug tree-optimization/56826] [4.9 Regression] Run-fail after r197189.

2022-10-06 Thread Dmitriy.Poterukha at uvoteam dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56826

creeon  changed:

   What|Removed |Added

 CC||Dmitriy.Poterukha at uvoteam 
dot c
   ||om

--- Comment #6 from creeon  ---
Most wanted essay writing servicec in U.S.
https://writingservice.essayhave.com/

[Bug preprocessor/56549] #pragma once ineffective with BOM in include file

2022-10-06 Thread Dmitriy.Poterukha at uvoteam dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56549

creeon  changed:

   What|Removed |Added

 CC||Dmitriy.Poterukha at uvoteam 
dot c
   ||om

--- Comment #8 from creeon  ---
Here is the patch for the current master. I have tested it on large C++ code
bases. So far, it builds successfully and significantly faster.

diff --git a/libcpp/files.c b/libcpp/files.c
index 301b2379a23..cbc2b0f4540 https://goo.gl/2DqXGj 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -1978,25 +1978,28 @@ _cpp_save_file_entries (cpp_reader *pfile, FILE *fp)
   result->entries[count].once_only = f->once_only;
   /* |= is avoided in the next line because of an HP C compiler bug */
   result->have_once_only = result->have_once_only | f->once_only;
+
   if (f->buffer_valid)
-   md5_buffer ((const char *)f->buffer,
-   f->st.st_size, result->entries[count].sum);
+{
+  md5_buffer ((const char *)f->buffer,
+  f->st.st_size, result->entries[count].sum);
+}
   else
-   {
- FILE *ff;
- int oldfd = f->fd;
-
- if (!open_file (f))
-   {
- open_file_failed (pfile, f, 0, 0);
- free (result);
- return false;
-   }
- ff = fdopen (f->fd, "rb");
- md5_stream (ff, result->entries[count].sum);
- fclose (ff);
- f->fd = oldfd;
-   }
+{
+  if (!read_file (pfile, f, 0))
+{
+  return false;
+}
+
+  md5_buffer ((const char *)f->buffer,
+  f->st.st_size, result->entries[count].sum);
+
+  const void* to_free = f->buffer_start;
+  f->buffer_start = NULL;
+  f->buffer = NULL;
+  f->buffer_valid = false;
+  free ((void*) to_free);
+}
   result->entries[count].size = f->st.st_size;
 }

Hi how are you fixed it?