Commit 81a0dcdb authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

sizeof(optval) must be 1 for IP_MULTICAST_TTL & IP_MULTICAST_LOOP. fixes #34.

parent 3dad125a
......@@ -433,8 +433,13 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
mrb_int i = mrb_test(optval) ? 1 : 0;
optval = mrb_str_new(mrb, (char *)&i, sizeof(i));
} else if (mrb_fixnum_p(optval)) {
mrb_int i = mrb_fixnum(optval);
optval = mrb_str_new(mrb, (char *)&i, sizeof(i));
if (optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_LOOP) {
char uc = mrb_fixnum(optval);
optval = mrb_str_new(mrb, &uc, sizeof(uc));
} else {
mrb_int i = mrb_fixnum(optval);
optval = mrb_str_new(mrb, (char *)&i, sizeof(i));
}
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "optval should be true, false, an integer, or a string");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment