Skip to content

Commit

Permalink
Zero out all fields of addrinfo hints
Browse files Browse the repository at this point in the history
getaddrinfo(3) explicitly says these fields have to be zero:

> All the other fields in the structure pointed to by hints
> must contain either 0 or a null pointer, as appropriate.

FreeBSD will fail with EAI_BADHINTS as hints contain garbage:
https://github.com/freebsd/freebsd/blob/29cbcfe994c6984bf993b7587b429668ce5073a8/lib/libc/net/getaddrinfo.c#L429-L431
  • Loading branch information
avsej committed Jun 21, 2017
1 parent eb56198 commit 51ae6f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mrb_uv.c
Expand Up @@ -533,7 +533,7 @@ mrb_uv_getaddrinfo(mrb_state *mrb, mrb_value self)
mrb_value node, service, b = mrb_nil_value(), req_val;
mrb_value mrb_hints = mrb_hash_new(mrb);
mrb_uv_req_t* req;
struct addrinfo hints;
struct addrinfo hints = {0};
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = 0;
hints.ai_protocol = 0;
Expand Down

0 comments on commit 51ae6f8

Please sign in to comment.