Commit e13a43f
committed
route: use length from message to parse netmask
sizeofSockaddrInet is 16, but first byte of sockaddr specifies the size
of the address. 16 works for most cases, except with Netmasks addresses,
on Darwin where only the significant bits are in the msg.
i.e. ipv4
06 02 00 00 ff ff
The above byte sequence is for a sockaddr that is 6 bytes long
representing an ipv4 for address that is 255.255.0.0.
i.e. ipv6 netmask
0e 1e 00 00 00 00 00 00 ff ff ff ff ff ff 00 00
The above is /48 netmask that should also be parsed as such.
Confirmed by using `route monitor`.
sources:
https://github.com/apple/darwin-xnu/blob/main/bsd/net/route.h
https://github.com/apple/darwin-xnu/blob/main/bsd/sys/socket.h#L6031 parent 35b4aba commit e13a43f
1 file changed
+22
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | | - | |
| 179 | + | |
176 | 180 | | |
177 | 181 | | |
| 182 | + | |
178 | 183 | | |
179 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
180 | 189 | | |
181 | 190 | | |
182 | | - | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | | - | |
186 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
187 | 204 | | |
188 | 205 | | |
189 | 206 | | |
| |||
0 commit comments