bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] rpctrace: Print beyond '\0' in MACH_MSG_TYPE_CHAR.


From: Kalle Olavi Niemitalo
Subject: [PATCH] rpctrace: Print beyond '\0' in MACH_MSG_TYPE_CHAR.
Date: Wed, 24 Aug 2016 00:41:30 +0300
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux)

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.
---

I do not intend to assign copyright to the FSF, but perhaps this
code change is simple enough not to be copyrightable.
The commit message is longer, though.

A sample line of output with this patch:

  160<--159(pid22050)->file_exec_file_name ( task132(pid22050) 0 "/bin/stty" 
"stty\0sane\0" "MAIL=/var/mail/kalle\0SSH_CLIENT=10.0.2.2 50161 
22\0USER=kalle\0SHLVL=1\0LD_ORIGIN_P" {  6<--140(pid22050)   6<--140(pid22050)  
 6<--140(pid22050)   126<--142(pid22050)} {  107<--143(pid22050)   
109<--144(pid22050)   85<--145(pid22050)   141<--146(pid22050)   
115<--147(pid22050) (null)} {18 0 0 0 0} pn{ 16  18  19   7   8   9  10  11   0 
  5   5   5   6} pn{ 12}) = 0 

The argv and envp arguments are no longer truncated at the first
null character.  The envp argument is still truncated at the
default 80-char limit.

 utils/rpctrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index 276377c..25d9bc6 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 == ' ')
            {
-- 
2.1.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]