Messages in this thread | | | Subject | Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers | From | Andy Shevchenko <> | Date | Thu, 15 Mar 2018 15:07:04 +0200 |
| |
On Thu, 2018-03-15 at 16:58 +0900, Sergey Senozhatsky wrote: > On (03/14/18 15:09), Petr Mladek wrote: >
> > char *pointer(const char *fmt, char *buf, char *end, void *ptr, > > struct printf_spec spec) > > { > > + static const char data_access_fmt[] = > > "RrhbMmIiEUVNadCDgGO"; > > const int default_width = 2 * sizeof(void *); > > + const char *err_msg = NULL; > > + > > + /* Prevent silent crash when this is called under > > logbuf_lock. */ > > + if (*fmt && strchr(data_access_fmt, *fmt) != NULL) > > + err_msg = check_pointer_access(ptr); > > Agree with Rasmus, I think switch() is easier. >
One more to the same.
Though need to add that we also have to append / update some comment to keep these lists synchronized (in Documentation, around pointer() and here)
-- Andy Shevchenko <andriy.shevchenko@linux.intel.com> Intel Finland Oy
| |