mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-27 16:39:08 +00:00
Make the ioctl() interface cleaner with regard to types: use size_t
instead of int where the variable has to hold buffer lengths, use u_int for things like number of network interfaces which in principle can never be negative.
This commit is contained in:
parent
da2f008200
commit
dd937e32bd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118160
@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
static int atm_physif_ioctl(int, caddr_t, caddr_t);
|
||||
static int atm_if_ioctl(struct ifnet *, u_long, caddr_t);
|
||||
static int atm_ifparse(char *, char *, int, int *);
|
||||
static int atm_ifparse(const char *, char *, size_t, int *);
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
@ -304,7 +304,9 @@ atm_physif_ioctl(code, data, arg)
|
||||
struct air_int_rsp apr;
|
||||
struct air_netif_rsp anr;
|
||||
struct air_cfg_rsp acr;
|
||||
int count, len, buf_len = aip->air_buf_len;
|
||||
u_int count;
|
||||
size_t len;
|
||||
size_t buf_len = aip->air_buf_len;
|
||||
int err = 0;
|
||||
char ifname[2*IFNAMSIZ];
|
||||
struct ifaddr *ifa;
|
||||
@ -1020,14 +1022,12 @@ atm_if_ioctl(ifp, cmd, data)
|
||||
*
|
||||
*/
|
||||
static int
|
||||
atm_ifparse(name, namep, size, unitp)
|
||||
char *name;
|
||||
char *namep;
|
||||
int size;
|
||||
int *unitp;
|
||||
atm_ifparse(const char *name, char *namep, size_t size, int *unitp)
|
||||
{
|
||||
char *cp, *np;
|
||||
int len = 0, unit = 0;
|
||||
const char *cp;
|
||||
char *np;
|
||||
size_t len = 0;
|
||||
int unit = 0;
|
||||
|
||||
/*
|
||||
* Separate supplied string into name and unit parts.
|
||||
@ -1135,4 +1135,3 @@ atm_nifname(name)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ struct atmsetreq {
|
||||
Atm_addr asru_arp_addr; /* ARP srvr address */
|
||||
Atm_addr asru_arp_subaddr;/* ARP srvr subaddr */
|
||||
caddr_t asru_arp_pbuf; /* Prefix buffer addr */
|
||||
int asru_arp_plen; /* Prefix buffer len */
|
||||
size_t asru_arp_plen; /* Prefix buffer len */
|
||||
} asru_asrvr;
|
||||
/* MAC address */
|
||||
struct {
|
||||
@ -84,7 +84,7 @@ struct atmsetreq {
|
||||
struct {
|
||||
char asru_nif_intf[IFNAMSIZ];/* Interface name */
|
||||
char asru_nif_pref[IFNAMSIZ];/* I/f prefix name */
|
||||
int asru_nif_cnt; /* Number of i/fs */
|
||||
u_int asru_nif_cnt; /* Number of i/fs */
|
||||
} asru_nif;
|
||||
/* NSAP prefix */
|
||||
struct {
|
||||
@ -198,7 +198,7 @@ struct atmdelreq {
|
||||
struct atminfreq {
|
||||
int air_opcode; /* Sub-operation */
|
||||
caddr_t air_buf_addr; /* Buffer for returned info */
|
||||
int air_buf_len; /* Buffer length */
|
||||
size_t air_buf_len; /* Buffer length */
|
||||
union {
|
||||
/* Vendor info */
|
||||
char airu_vinfo_intf[IFNAMSIZ];/* Interface name */
|
||||
@ -247,7 +247,7 @@ struct atminfreq {
|
||||
*/
|
||||
struct air_vinfo_rsp {
|
||||
char avsp_intf[IFNAMSIZ]; /* Interface name */
|
||||
int avsp_len; /* Length of returned
|
||||
size_t avsp_len; /* Length of returned
|
||||
Vendor Info block */
|
||||
/* Vendor info ... */
|
||||
};
|
||||
@ -311,7 +311,7 @@ struct air_int_rsp {
|
||||
u_char anp_sig_proto; /* Signalling protocol */
|
||||
u_char anp_sig_state; /* Signalling protocol state */
|
||||
char anp_nif_pref[IFNAMSIZ]; /* Netif prefix */
|
||||
int anp_nif_cnt; /* No. of netifs */
|
||||
u_int anp_nif_cnt; /* No. of netifs */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -341,12 +341,12 @@ struct air_vcc_rsp {
|
||||
char avp_owners[(T_ATM_APP_NAME_LEN+1)*O_CNT];/* VCC users */
|
||||
Atm_addr avp_daddr; /* Address of far end */
|
||||
Atm_addr avp_dsubaddr; /* Subaddress of far end */
|
||||
long avp_ipdus; /* PDUs received from VCC */
|
||||
long avp_opdus; /* PDUs sent to VCC */
|
||||
long avp_ibytes; /* Bytes received from VCC */
|
||||
long avp_obytes; /* Bytes sent to VCC */
|
||||
long avp_ierrors; /* Errors receiving from VCC */
|
||||
long avp_oerrors; /* Errors sending to VCC */
|
||||
u_long avp_ipdus; /* PDUs received from VCC */
|
||||
u_long avp_opdus; /* PDUs sent to VCC */
|
||||
u_long avp_ibytes; /* Bytes received from VCC */
|
||||
u_long avp_obytes; /* Bytes sent to VCC */
|
||||
u_long avp_ierrors; /* Errors receiving from VCC */
|
||||
u_long avp_oerrors; /* Errors sending to VCC */
|
||||
time_t avp_tstamp; /* State transition timestamp */
|
||||
};
|
||||
|
||||
|
@ -382,7 +382,7 @@ atm_dgram_control(so, cmd, data, ifp, td)
|
||||
* Validate interface count - logical interfaces
|
||||
* are differentiated by the atm address selector.
|
||||
*/
|
||||
if ((asp->asr_nif_cnt <= 0) || (asp->asr_nif_cnt > 256))
|
||||
if (asp->asr_nif_cnt == 0 || asp->asr_nif_cnt > 256)
|
||||
ATM_RETERR(EINVAL);
|
||||
|
||||
/*
|
||||
|
@ -58,12 +58,12 @@ struct vccb {
|
||||
u_short vc_vpi; /* Virtual Path Identifier */
|
||||
u_short vc_vci; /* Virtual Channel Identifier */
|
||||
Atm_connvc *vc_connvc; /* CM connection VCC instance */
|
||||
long vc_ipdus; /* PDUs received from VCC */
|
||||
long vc_opdus; /* PDUs sent to VCC */
|
||||
long vc_ibytes; /* Bytes received from VCC */
|
||||
long vc_obytes; /* Bytes sent to VCC */
|
||||
long vc_ierrors; /* Errors receiving from VCC */
|
||||
long vc_oerrors; /* Errors sending to VCC */
|
||||
u_long vc_ipdus; /* PDUs received from VCC */
|
||||
u_long vc_opdus; /* PDUs sent to VCC */
|
||||
u_long vc_ibytes; /* Bytes received from VCC */
|
||||
u_long vc_obytes; /* Bytes sent to VCC */
|
||||
u_long vc_ierrors; /* Errors receiving from VCC */
|
||||
u_long vc_oerrors; /* Errors sending to VCC */
|
||||
time_t vc_tstamp; /* State transition timestamp */
|
||||
};
|
||||
#endif /* _KERNEL */
|
||||
|
@ -90,7 +90,8 @@ ipatm_ioctl(code, data, arg1)
|
||||
struct ipatmpvc pv;
|
||||
caddr_t cp;
|
||||
struct in_addr ip;
|
||||
int space, err = 0;
|
||||
int err = 0;
|
||||
size_t space;
|
||||
struct t_atm_traffic *traf;
|
||||
|
||||
|
||||
|
@ -555,9 +555,11 @@ sigpvc_ioctl(code, data, arg1)
|
||||
Atm_connection *cop;
|
||||
caddr_t cp;
|
||||
u_int vpi, vci;
|
||||
int i, space, err = 0;
|
||||
|
||||
int err;
|
||||
size_t space;
|
||||
size_t tlen;
|
||||
|
||||
err = 0;
|
||||
switch (code) {
|
||||
|
||||
case AIOCS_DEL_PVC:
|
||||
@ -633,10 +635,10 @@ sigpvc_ioctl(code, data, arg1)
|
||||
else
|
||||
avr.avp_encaps = 0;
|
||||
bzero(avr.avp_owners, sizeof(avr.avp_owners));
|
||||
for (i = 0; cop && i < sizeof(avr.avp_owners);
|
||||
for (tlen = 0; cop && tlen < sizeof(avr.avp_owners);
|
||||
cop = cop->co_next,
|
||||
i += T_ATM_APP_NAME_LEN+1) {
|
||||
strncpy(&avr.avp_owners[i],
|
||||
tlen += T_ATM_APP_NAME_LEN + 1) {
|
||||
strncpy(&avr.avp_owners[tlen],
|
||||
cop->co_endpt->ep_getname(cop->co_toku),
|
||||
T_ATM_APP_NAME_LEN);
|
||||
}
|
||||
|
@ -927,7 +927,8 @@ spansarp_ioctl(code, data, arg1)
|
||||
struct ipvcc *ivp, *inext;
|
||||
struct in_addr ip;
|
||||
u_long dst;
|
||||
int err = 0, i, buf_len;
|
||||
int err = 0, i;
|
||||
size_t buf_len;
|
||||
caddr_t buf_addr;
|
||||
|
||||
|
||||
|
@ -906,7 +906,8 @@ spans_ioctl(code, data, arg1)
|
||||
struct spans_vccb *svp;
|
||||
struct air_vcc_rsp rsp;
|
||||
Atm_connection *cop;
|
||||
int buf_len, err = 0, i, vpi, vci;
|
||||
int err = 0, i, vpi, vci;
|
||||
size_t buf_len;
|
||||
caddr_t buf_addr;
|
||||
|
||||
|
||||
|
@ -864,7 +864,9 @@ uniarp_ioctl(code, data, arg1)
|
||||
struct in_addr ip;
|
||||
Atm_addr atmsub;
|
||||
u_long dst;
|
||||
int err = 0, i, buf_len;
|
||||
int err = 0;
|
||||
size_t buf_len, tlen;
|
||||
u_int i;
|
||||
caddr_t buf_addr;
|
||||
|
||||
switch (code) {
|
||||
@ -962,7 +964,7 @@ uniarp_ioctl(code, data, arg1)
|
||||
*/
|
||||
if (asp->asr_arp_addr.address_format == T_ATM_ABSENT) {
|
||||
i = asp->asr_arp_plen / sizeof(struct uniarp_prf);
|
||||
if (i <= 0) {
|
||||
if (i == 0) {
|
||||
err = EINVAL;
|
||||
break;
|
||||
}
|
||||
@ -1215,16 +1217,17 @@ uniarp_ioctl(code, data, arg1)
|
||||
* Copy the prefix list into the user's buffer
|
||||
*/
|
||||
if (uip->uip_nprefix) {
|
||||
i = uip->uip_nprefix
|
||||
* sizeof(struct uniarp_prf);
|
||||
if (buf_len < i) {
|
||||
tlen = uip->uip_nprefix *
|
||||
sizeof(struct uniarp_prf);
|
||||
if (buf_len < tlen) {
|
||||
err = ENOSPC;
|
||||
break;
|
||||
}
|
||||
if ((err = copyout(uip->uip_prefix, buf_addr, i)) != 0)
|
||||
err = copyout(uip->uip_prefix, buf_addr, tlen);
|
||||
if (err != 0)
|
||||
break;
|
||||
buf_addr += i;
|
||||
buf_len -= i;
|
||||
buf_addr += tlen;
|
||||
buf_len -= tlen;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ uniarp_validate_ip(uip, ip, origin)
|
||||
u_int origin;
|
||||
{
|
||||
struct uniarp_prf *upp;
|
||||
int i;
|
||||
u_int i;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -822,7 +822,8 @@ unisig_ioctl(code, data, arg1)
|
||||
struct atm_pif *pip;
|
||||
Atm_connection *cop;
|
||||
u_int vpi, vci;
|
||||
int err = 0, buf_len, i;
|
||||
int err = 0, i;
|
||||
size_t buf_len;
|
||||
caddr_t buf_addr;
|
||||
|
||||
ATM_DEBUG1("unisig_ioctl: code=%d\n", code);
|
||||
|
Loading…
Reference in New Issue
Block a user