Current-Users archive

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

Re: netbsd-8: panic: sockaddr_copy: source too long, 28 < 128 bytes



On Mon, Nov 5, 2018 at 12:38 PM Ryota Ozaki <ozaki-r%netbsd.org@localhost> wrote:
>
(snip)
>
> I can reproduce the panic easily by the small program:
>
> // start--
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <err.h>
>
> int
> main(void)
> {
>         char buf[64];
>         struct sockaddr_storage ss = {0};
>         int s, e;
>
>         ss.ss_family = AF_INET6;
>         ss.ss_len = sizeof(struct sockaddr_in6);

Oops. sin6_addr and sin6_port (of ss casted to sockaddr_in6)
should not be zero and so be set some 1.

  ozaki-r

>         s = socket(AF_INET6, SOCK_DGRAM, 0);
>         e = sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)&ss, ss.ss_len);
>         if (e == -1)
>                 warn("sendto");
>         ss.ss_len = sizeof(ss);
>         e = sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)&ss, ss.ss_len);
>         if (e == -1)
>                 warn("sendto");
> }
> // --end


Home | Main Index | Thread Index | Old Index