]> granicus.if.org Git - strace/blobdiff - hostname.c
tests: check decoding of netlink smc_diag_msg attributes
[strace] / hostname.c
index c64d954dad9beb2faefa579bd30d49d49991c726..75f96ba69c3e0314ea11e1044e757fe5352ac513 100644 (file)
@@ -1,9 +1,24 @@
 #include "defs.h"
 
+#ifdef HAVE_LINUX_UTSNAME_H
+# include <linux/utsname.h>
+#endif
+
+#ifndef __NEW_UTS_LEN
+# define __NEW_UTS_LEN 64
+#endif
+
 SYS_FUNC(sethostname)
 {
-       printstr(tcp, tcp->u_arg[0], tcp->u_arg[1]);
-       tprintf(", %lu", tcp->u_arg[1]);
+       unsigned int len = tcp->u_arg[1];
+
+       if (len > __NEW_UTS_LEN) {
+               printaddr(tcp->u_arg[0]);
+       } else {
+               printstrn(tcp, tcp->u_arg[0], len);
+       }
+
+       tprintf(", %u", len);
 
        return RVAL_DECODED;
 }
@@ -15,8 +30,8 @@ SYS_FUNC(gethostname)
                if (syserror(tcp))
                        printaddr(tcp->u_arg[0]);
                else
-                       printstr(tcp, tcp->u_arg[0], -1);
-               tprintf(", %lu", tcp->u_arg[1]);
+                       printstr(tcp, tcp->u_arg[0]);
+               tprintf(", %" PRI_klu, tcp->u_arg[1]);
        }
        return 0;
 }