correct more out-of-bounds memory access, if cnt == 1 and optlen > 1.

similar to recent fix to sys/netinet/ipf.c (by darren).
This commit is contained in:
Jun-ichiro itojun Hagino 2000-05-10 01:25:33 +00:00
parent fc81cf82e9
commit fdcb8debf6

View File

@ -1078,6 +1078,10 @@ ip_dooptions(m)
if (opt == IPOPT_NOP)
optlen = 1;
else {
if (cnt < IPOPT_OLEN + sizeof(*cp)) {
code = &cp[IPOPT_OLEN] - (u_char *)ip;
goto bad;
}
optlen = cp[IPOPT_OLEN];
if (optlen <= 0 || optlen > cnt) {
code = &cp[IPOPT_OLEN] - (u_char *)ip;