From ca5b01f538c122dc1f0e989f5703c75b8cf8ca3a Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Wed, 24 Aug 2016 00:41:30 +0300 Subject: rpctrace: Print beyond '\0' in MACH_MSG_TYPE_CHAR. This will now display the 'argv: data_t' argument of file_exec as e.g. "who\0am\0i\0" rather than just "who". In contrast, the 'file_name: string_t' argument of dir_lookup will still be truncated at the first null character. The previous implementation might crash if an out-of-line char array exactly fills a page and does not contain any null characters. * utils/rpctrace.c (print_data): On MACH_MSG_TYPE_STRING and MACH_MSG_TYPE_CHAR, check for end of buffer before checking for a null character. On MACH_MSG_TYPE_CHAR only, continue printing past null characters. --- utils/rpctrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/rpctrace.c b/utils/rpctrace.c index 276377c0..25d9bc6e 100644 --- a/utils/rpctrace.c +++ b/utils/rpctrace.c @@ -1524,7 +1524,8 @@ print_data (mach_msg_type_name_t type, the first character that has not yet been printed. */ const char *p, *q; p = q = (const char *) data; - while (q && *q && q - (const char *) data < (int) (nelt * eltsize)) + while (q && q - (const char *) data < (int) (nelt * eltsize) + && (*q || type == MACH_MSG_TYPE_CHAR)) { if (isgraph (*q) || *q == ' ') { -- cgit v1.2.3