Currently, a 15 character debug channel name (e.g. `WINE_DEFAULT_DEBUG_CHANNEL(mediacontroller)`) results in no null-terminator at the end of the debug channel name array (`char name[15]`), and no compiler warning. A 16+ character name does throw an excess-initializers warning.
Arguably, the debug channel name should be treated as a fixed-length string and not null-terminated, but this would require changes in a number of places (`winedbg`, `taskmgr`, `ntdll`, `winecrt0`). Also, overly-long channel names would still only result in truncation and a compiler warning rather than an error.
From: Brendan Shanks bshanks@codeweavers.com
--- include/wine/debug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/wine/debug.h b/include/wine/debug.h index 86e008a1408..ce5e141ccb7 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -501,9 +501,11 @@ static inline const char *wine_dbgstr_variant( const VARIANT *v ) #define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch)
#define WINE_DECLARE_DEBUG_CHANNEL(ch) \ - static struct __wine_debug_channel __wine_dbch_##ch = { 0xff, #ch } + static struct __wine_debug_channel __wine_dbch_##ch = { 0xff, #ch }; \ + C_ASSERT(sizeof(#ch) <= sizeof(__wine_dbch_##ch.name)) #define WINE_DEFAULT_DEBUG_CHANNEL(ch) \ static struct __wine_debug_channel __wine_dbch_##ch = { 0xff, #ch }; \ + C_ASSERT(sizeof(#ch) <= sizeof(__wine_dbch_##ch.name)); \ static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
#define WINE_MESSAGE wine_dbg_printf