Print this page
4142 truss should expand connect() arguments

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/truss/expound.c
          +++ new/usr/src/cmd/truss/expound.c
↓ open down ↓ 3477 lines elided ↑ open up ↑
3478 3478  }
3479 3479  
3480 3480  void
3481 3481  show_sockaddr(private_t *pri,
3482 3482          const char *str, long addroff, long lenoff, long len)
3483 3483  {
3484 3484          /*
3485 3485           * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3486 3486           * also large enough to store a sockaddr_in or a sockaddr_in6.
3487 3487           */
3488      -        long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3489      -            / sizeof (long)];
3490      -        struct sockaddr *sa = (struct sockaddr *)buf;
3491      -        struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3492      -        struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3493      -        struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
     3488 +        struct sockaddr_storage buf;
     3489 +
     3490 +        struct sockaddr *sa = (struct sockaddr *)&buf;
     3491 +        struct sockaddr_in *sin = (struct sockaddr_in *)&buf;
     3492 +        struct sockaddr_un *soun = (struct sockaddr_un *)&buf;
     3493 +        struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&buf;
3494 3494          char addrbuf[INET6_ADDRSTRLEN];
3495 3495  
3496 3496          if (lenoff != 0) {
3497 3497                  uint_t ilen;
3498 3498                  if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3499 3499                          return;
3500 3500                  len = ilen;
3501 3501          }
3502 3502  
3503 3503          if (len >= sizeof (buf))        /* protect against ridiculous length */
3504 3504                  len = sizeof (buf) - 1;
3505      -        if (Pread(Proc, buf, len, addroff) != len)
     3505 +        if (Pread(Proc, (void*)&buf, len, addroff) != len)
3506 3506                  return;
3507 3507  
3508 3508          switch (sa->sa_family) {
3509 3509          case AF_INET6:
3510 3510                  (void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
3511 3511                      pri->pname, str,
3512 3512                      inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3513 3513                      sizeof (addrbuf)),
3514 3514                      ntohs(sin6->sin6_port));
3515 3515                  (void) printf("%s\tscope id = %u  source id = 0x%x\n"
↓ open down ↓ 2090 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX