You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3565 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Samuel Thibault
Version: 3.08.3
OS: Linux
Submission from: d83-177-178-162.cust.tele2.fr (83.177.178.162)
Hi,
While trying to use ipv6 with Ocaml, getaddrinfo returned me strange results. My
/etc/hosts contains
fec0::2d0:59ff:fe4b:1b2e interface.ipv6
and ping6 interface.ipv6 does work, so C resolving works, but:
open Unix;;
let [ ai ] = getaddrinfo "interface.ipv6" "12345" [AI_SOCKTYPE SOCK_STREAM];;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val ai : Unix.addr_info =
{ai_family = PF_INET6; ai_socktype = SOCK_STREAM; ai_protocol = 6;
ai_addr = ADDR_INET (, 12345); ai_canonname = ""}
let ADDR_INET(adr,port) = ai.ai_addr;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
ADDR_UNIX _
val adr : Unix.inet_addr =
val port : int = 12345
string_of_inet_addr adr;;
: string = "fec0::90e8:ffbf:200:0"
Which is just garbage. In otherlibs/unix/getaddrinfo.c, I noticed the following
lines in convert_addrinfo():
memcpy(&sa.s_gen, a->ai_addr, sizeof(struct sockaddr));
vaddr = alloc_sockaddr(&sa, sizeof(struct sockaddr), -1);
This is wrong: struct sockaddr is not always big enough to hold struct
sockaddr_in6 for instance. sizeof(struct sockaddr) should be replaced by
a->ai_addrlen for instance (after checking that this is smaller than caml's
sizeof(union sock_addr_union) ), in which case it does work:
open Unix;;
let [ ai ] = getaddrinfo "interface.ipv6" "12345" [AI_SOCKTYPE SOCK_STREAM];;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val ai : Unix.addr_info =
{ai_family = PF_INET6; ai_socktype = SOCK_STREAM; ai_protocol = 6;
ai_addr = ADDR_INET (, 12345); ai_canonname = ""}
let ADDR_INET(adr,port) = ai.ai_addr;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
ADDR_UNIX _
val adr : Unix.inet_addr =
val port : int = 12345
string_of_inet_addr adr;;
: string = "fec0::2d0:59ff:fe4b:1b2e"
Regards,
Samuel Thibault
The text was updated successfully, but these errors were encountered:
Original bug ID: 3565
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Samuel Thibault
Version: 3.08.3
OS: Linux
Submission from: d83-177-178-162.cust.tele2.fr (83.177.178.162)
Hi,
While trying to use ipv6 with Ocaml, getaddrinfo returned me strange results. My
/etc/hosts contains
fec0::2d0:59ff:fe4b:1b2e interface.ipv6
and ping6 interface.ipv6 does work, so C resolving works, but:
open Unix;;
let [ ai ] = getaddrinfo "interface.ipv6" "12345" [AI_SOCKTYPE SOCK_STREAM];;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val ai : Unix.addr_info =
{ai_family = PF_INET6; ai_socktype = SOCK_STREAM; ai_protocol = 6;
ai_addr = ADDR_INET (, 12345); ai_canonname = ""}
let ADDR_INET(adr,port) = ai.ai_addr;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
ADDR_UNIX _
val adr : Unix.inet_addr =
val port : int = 12345
string_of_inet_addr adr;;
Which is just garbage. In otherlibs/unix/getaddrinfo.c, I noticed the following
lines in convert_addrinfo():
memcpy(&sa.s_gen, a->ai_addr, sizeof(struct sockaddr));
vaddr = alloc_sockaddr(&sa, sizeof(struct sockaddr), -1);
This is wrong: struct sockaddr is not always big enough to hold struct
sockaddr_in6 for instance. sizeof(struct sockaddr) should be replaced by
a->ai_addrlen for instance (after checking that this is smaller than caml's
sizeof(union sock_addr_union) ), in which case it does work:
open Unix;;
let [ ai ] = getaddrinfo "interface.ipv6" "12345" [AI_SOCKTYPE SOCK_STREAM];;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val ai : Unix.addr_info =
{ai_family = PF_INET6; ai_socktype = SOCK_STREAM; ai_protocol = 6;
ai_addr = ADDR_INET (, 12345); ai_canonname = ""}
let ADDR_INET(adr,port) = ai.ai_addr;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
ADDR_UNIX _
val adr : Unix.inet_addr =
val port : int = 12345
string_of_inet_addr adr;;
Regards,
Samuel Thibault
The text was updated successfully, but these errors were encountered: