Mercurial > hg > dhcpcd
changeset 4514:707d58bf0352 draft
BSD: Ensure we have enough of a RTM message to read it.
As not all are of equal size.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Sat, 04 May 2019 14:29:28 +0100 |
| parents | 41bf9c12f9ad |
| children | 2b33154f3442 |
| files | src/dhcpcd.c src/if-bsd.c src/if-sun.c |
| diffstat | 3 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Sat May 04 13:53:07 2019 +0100 +++ b/src/dhcpcd.c Sat May 04 14:29:28 2019 +0100 @@ -1081,8 +1081,7 @@ dhcpcd_linkoverflow(ctx); return; } - if (errno != ENOTSUP) - logerr(__func__); + logerr(__func__); } }
--- a/src/if-bsd.c Sat May 04 13:53:07 2019 +0100 +++ b/src/if-bsd.c Sat May 04 14:29:28 2019 +0100 @@ -1063,7 +1063,7 @@ return 0; if (if_copyrt(ctx, &rt, rtm) == -1) - return -1; + return errno == ENOTSUP ? 0 : -1; #ifdef INET6 /* @@ -1326,7 +1326,9 @@ return -1; if (len == 0) return 0; - if (len < rtm.hdr.rtm_msglen) { + if ((size_t)len < offsetof(struct rt_msghdr, rtm_index) || + len < rtm.hdr.rtm_msglen) + { errno = EINVAL; return -1; }
--- a/src/if-sun.c Sat May 04 13:53:07 2019 +0100 +++ b/src/if-sun.c Sat May 04 14:29:28 2019 +0100 @@ -1078,7 +1078,9 @@ return -1; if (len == 0) return 0; - if (len < rtm.hdr.rtm_msglen) { + if ((size_t)len < offsetof(struct rt_msghdr, rtm_index) || + len < rtm.hdr.rtm_msglen) + { errno = EINVAL; return -1; }
