Fix a bug in r272840; given that the optlen parameter of setsockopt(2)
is a 32-bit socklen_t, do_get3() passes the kernel to access the wrong 32-bit half on big-endian LP64 machines when simply casting the 64-bit size_t optlen to a socklen_t pointer. While at it and given that the intention of do_get3() apparently is to hide/wrap the fact that socket options are used for communication with ipfw(4), change the optlen parameter of do_set3() to be of type size_t and as such more appropriate than uintptr_t, too. MFC after: 3 days
This commit is contained in:
parent
6ecbf62ad2
commit
35fedb74e5
@ -591,7 +591,7 @@ do_cmd(int optname, void *optval, uintptr_t optlen)
|
||||
* Returns 0 on success or errno otherwise.
|
||||
*/
|
||||
int
|
||||
do_set3(int optname, ip_fw3_opheader *op3, uintptr_t optlen)
|
||||
do_set3(int optname, ip_fw3_opheader *op3, size_t optlen)
|
||||
{
|
||||
|
||||
if (co.test_only)
|
||||
@ -621,6 +621,7 @@ int
|
||||
do_get3(int optname, ip_fw3_opheader *op3, size_t *optlen)
|
||||
{
|
||||
int error;
|
||||
socklen_t len;
|
||||
|
||||
if (co.test_only)
|
||||
return (0);
|
||||
@ -632,8 +633,9 @@ do_get3(int optname, ip_fw3_opheader *op3, size_t *optlen)
|
||||
|
||||
op3->opcode = optname;
|
||||
|
||||
error = getsockopt(ipfw_socket, IPPROTO_IP, IP_FW3, op3,
|
||||
(socklen_t *)optlen);
|
||||
len = *optlen;
|
||||
error = getsockopt(ipfw_socket, IPPROTO_IP, IP_FW3, op3, &len);
|
||||
*optlen = len;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ void print_flags_buffer(char *buf, size_t sz, struct _s_x *list, uint32_t set);
|
||||
|
||||
struct _ip_fw3_opheader;
|
||||
int do_cmd(int optname, void *optval, uintptr_t optlen);
|
||||
int do_set3(int optname, struct _ip_fw3_opheader *op3, uintptr_t optlen);
|
||||
int do_set3(int optname, struct _ip_fw3_opheader *op3, size_t optlen);
|
||||
int do_get3(int optname, struct _ip_fw3_opheader *op3, size_t *optlen);
|
||||
|
||||
struct in6_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user