From 6d00cfb2330cb47d00d350eedfbffbbf5991a743 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 12 Jan 2018 11:01:26 +0100 Subject: include/debug: don't print pointer address for SUID programs * introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing * use __UL_DEBUG_FL_NOADDR when SUID * move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK to provide access to the current mask from ul_debugobj(). It's better than modify all ul_debugobj() calls and use the global mask as argument. * remove never used UL_DEBUG_DEFINE_FLAG Reported-by: halfdog Signed-off-by: Karel Zak --- include/debugobj.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/debugobj.h (limited to 'include/debugobj.h') diff --git a/include/debugobj.h b/include/debugobj.h new file mode 100644 index 000000000..73b70b8df --- /dev/null +++ b/include/debugobj.h @@ -0,0 +1,22 @@ +#ifndef UTIL_LINUX_DEBUGOBJ_H +#define UTIL_LINUX_DEBUGOBJ_H + +/* + * Include *after* debug.h and after UL_DEBUG_CURRENT_MASK define. + */ + +static inline void __attribute__ ((__format__ (__printf__, 2, 3))) +ul_debugobj(const void *handler, const char *mesg, ...) +{ + va_list ap; + + if (handler && !(UL_DEBUG_CURRENT_MASK & __UL_DEBUG_FL_NOADDR)) + fprintf(stderr, "[%p]: ", handler); + + va_start(ap, mesg); + vfprintf(stderr, mesg, ap); + va_end(ap); + fputc('\n', stderr); +} + +#endif /* UTIL_LINUX_DEBUGOBJ_H */ -- cgit v1.2.3-55-g7522