Lines 6-11
Link Here
|
6 |
* Can be freely distributed and used under the terms of the GNU GPL. |
6 |
* Can be freely distributed and used under the terms of the GNU GPL. |
7 |
*/ |
7 |
*/ |
|
|
8 |
#include <assert.h> |
8 |
#include <stdio.h> |
9 |
#include <stdio.h> |
9 |
#include <stdlib.h> |
10 |
#include <stdlib.h> |
10 |
#include <ctype.h> |
11 |
#include <ctype.h> |
Lines 189-195
struct ks_msg
Link Here
|
189 |
static inline void |
189 |
static inline void |
190 |
sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa) |
190 |
sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa) |
191 |
{ |
191 |
{ |
192 |
uint len = OFFSETOF(struct sockaddr_dl, sdl_data); |
192 |
/* The original code does not work on FreeBSD 13.0. The kernel checks |
|
|
193 |
if the passed struct is properly initialized. It checks that len is at |
194 |
least as large as sizeof(sockaddr_dl_short). Unfortunately, |
195 |
sockaddr_dl_short is not defined in the user space header file. |
196 |
|
197 |
Also note that the caller only ever allocates `sizeof(struct sockaddr*)` |
198 |
for the `struct sockaddr_dl*` parameter, but sockaddr_dl is potentially |
199 |
much bigger. */ |
200 |
// uint len = OFFSETOF(struct sockaddr_dl, sdl_data); // buggy |
201 |
static_assert(sizeof(struct sockaddr) <= sizeof(struct sockaddr_dl)); |
202 |
uint len = sizeof(struct sockaddr); |
193 |
memset(sa, 0, len); |
203 |
memset(sa, 0, len); |
194 |
sa->sdl_len = len; |
204 |
sa->sdl_len = len; |
195 |
sa->sdl_family = AF_LINK; |
205 |
sa->sdl_family = AF_LINK; |