Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_spppsubr.c
Show First 20 Lines • Show All 5,038 Lines • ▼ Show 20 Lines | sppp_suggest_ip6_addr(struct sppp *sp, struct in6_addr *suggest) | ||||
if (suggest) | if (suggest) | ||||
bcopy(&myaddr, suggest, sizeof(myaddr)); | bcopy(&myaddr, suggest, sizeof(myaddr)); | ||||
} | } | ||||
#endif /*INET6*/ | #endif /*INET6*/ | ||||
static int | static int | ||||
sppp_params(struct sppp *sp, u_long cmd, void *data) | sppp_params(struct sppp *sp, u_long cmd, void *data) | ||||
{ | { | ||||
u_long subcmd; | |||||
struct ifreq *ifr = (struct ifreq *)data; | struct ifreq *ifr = (struct ifreq *)data; | ||||
struct spppreq *spr; | struct spppreq *spr; | ||||
int rv = 0; | int rv; | ||||
if ((spr = malloc(sizeof(struct spppreq), M_TEMP, M_NOWAIT)) == NULL) | if ((spr = malloc(sizeof(struct spppreq), M_TEMP, M_NOWAIT)) == NULL) | ||||
return (EAGAIN); | return (EAGAIN); | ||||
/* | /* | ||||
* ifr_data_get_ptr(ifr) is supposed to point to a struct spppreq. | * ifr_data_get_ptr(ifr) is supposed to point to a struct spppreq. | ||||
* Check the cmd word first before attempting to fetch all the | * Check the cmd word first before attempting to fetch all the | ||||
* data. | * data. | ||||
*/ | */ | ||||
rv = fueword(ifr_data_get_ptr(ifr), &subcmd); | rv = fuword32(ifr_data_get_ptr(ifr)); | ||||
zlei: After re-reading the code, I think I should use `fueword32` instead, as `rv` was not cleared in… | |||||
if (rv == -1) { | if (rv == -1) { | ||||
rv = EFAULT; | rv = EFAULT; | ||||
goto quit; | goto quit; | ||||
} | } | ||||
if (copyin(ifr_data_get_ptr(ifr), spr, sizeof(struct spppreq)) != 0) { | if (copyin(ifr_data_get_ptr(ifr), spr, sizeof(struct spppreq)) != 0) { | ||||
rv = EFAULT; | rv = EFAULT; | ||||
goto quit; | goto quit; | ||||
} | } | ||||
switch (subcmd) { | MPASS(rv == spr->cmd); | ||||
case (u_long)SPPPIOGDEFS: | switch (spr->cmd) { | ||||
case (intptr_t)SPPPIOGDEFS: | |||||
if (cmd != SIOCGIFGENERIC) { | if (cmd != SIOCGIFGENERIC) { | ||||
rv = EINVAL; | rv = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* We copy over the entire current state, but clean | * We copy over the entire current state, but clean | ||||
* out some of the stuff we don't wanna pass up. | * out some of the stuff we don't wanna pass up. | ||||
* Remember, SIOCGIFGENERIC is unprotected, and can be | * Remember, SIOCGIFGENERIC is unprotected, and can be | ||||
Show All 18 Lines | case (intptr_t)SPPPIOGDEFS: | ||||
* of "hz". We do the reverse calculation below when | * of "hz". We do the reverse calculation below when | ||||
* setting it. | * setting it. | ||||
*/ | */ | ||||
spr->defs.lcp.timeout = sp->lcp.timeout * 1000 / hz; | spr->defs.lcp.timeout = sp->lcp.timeout * 1000 / hz; | ||||
rv = copyout(spr, ifr_data_get_ptr(ifr), | rv = copyout(spr, ifr_data_get_ptr(ifr), | ||||
sizeof(struct spppreq)); | sizeof(struct spppreq)); | ||||
break; | break; | ||||
case (u_long)SPPPIOSDEFS: | case (intptr_t)SPPPIOSDEFS: | ||||
if (cmd != SIOCSIFGENERIC) { | if (cmd != SIOCSIFGENERIC) { | ||||
rv = EINVAL; | rv = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* We have a very specific idea of which fields we | * We have a very specific idea of which fields we | ||||
* allow being passed back from userland, so to not | * allow being passed back from userland, so to not | ||||
* clobber our current state. For one, we only allow | * clobber our current state. For one, we only allow | ||||
▲ Show 20 Lines • Show All 302 Lines • Show Last 20 Lines |
After re-reading the code, I think I should use fueword32 instead, as rv was not cleared in SPPPIOSDEFS switch branch. My local test only cover SPPPIOGDEFS branch, shame.