Repository navigation
Commit b98784e
committed
mruby-socket: declare both arguments of IPSocket.ntop
IPSocket.ntop(af, addr) was defined with MRB_ARGS_REQ(1) and reads two
arguments. Since the VM started checking a C method's declared arity, every call
with two arguments raises "wrong number of arguments (given 2, expected 1)", and
a call with one fails in mrb_get_args, so the method can't be called at all.
The length check only looked at the two families it knows, before the (int)
cast, so (1 << 32) + Socket::AF_INET6 skipped it and then read 16 bytes as
AF_INET6 whatever the length of addr. Accept only AF_INET with 4 bytes and
AF_INET6 with 16; inet_ntop refused any other family anyway.1 parent e0cf7fa commit b98784e
2 files changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
936 | | - | |
| 936 | + | |
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
| |||
1431 | 1431 | | |
1432 | 1432 | | |
1433 | 1433 | | |
1434 | | - | |
| 1434 | + | |
1435 | 1435 | | |
1436 | 1436 | | |
1437 | 1437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
17 | 35 | | |
18 | 36 | | |
19 | 37 | | |
| |||
0 commit comments