 if (copy_from_user(keybuf, erq->pointer, erq->length)) return -EFAULT; 
static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *erq){	struct orinoco_private *priv = netdev_priv(dev);	int index = (erq->flags & IW_ENCODE_INDEX) - 1;	int setindex = priv->tx_key;	int enable = priv->wep_on;	int restricted = priv->wep_restrict;	u16 xlen = 0;	int err = 0;	char keybuf[ORINOCO_MAX_KEY_SIZE];	unsigned long flags;	if (! priv->has_wep)		return -EOPNOTSUPP;	if (erq->pointer) {		/* We actually have a key to set - check its length */		if (erq->length > LARGE_KEY_SIZE)			return -E2BIG;		if ( (erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep )			return -E2BIG;				if (copy_from_user(keybuf, erq->pointer, erq->length))			return -EFAULT;	}	if (orinoco_lock(priv, &flags) != 0)		return -EBUSY;	if (erq->pointer) {		if ((index < 0) || (index >= ORINOCO_MAX_KEYS))			index = priv->tx_key;		/* Adjust key length to a supported value */		if (erq->length > SMALL_KEY_SIZE) {			xlen = LARGE_KEY_SIZE;		} else if (erq->length > 0) {			xlen = SMALL_KEY_SIZE;		} else			xlen = 0;		/* Switch on WEP if off */		if ((!enable) && (xlen > 0)) {			setindex = index;			enable = 1;		}	} else {		/* Important note : if the user do "iwconfig eth0 enc off",		 * we will arrive there with an index of -1. This is valid		 * but need to be taken care off... Jean II */		if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) {			if((index != -1) || (erq->flags == 0)) {				err = -EINVAL;				goto out;			}		} else {			/* Set the index : Check that the key is valid */			if(priv->keys[index].len == 0) {				err = -EINVAL;				goto out;			}			setindex = index;		}	}	if (erq->flags & IW_ENCODE_DISABLED)		enable = 0;	if (erq->flags & IW_ENCODE_OPEN)		restricted = 0;	if (erq->flags & IW_ENCODE_RESTRICTED)		restricted = 1;	if (erq->pointer) {		priv->keys[index].len = cpu_to_le16(xlen);		memset(priv->keys[index].data, 0,		       sizeof(priv->keys[index].data));		memcpy(priv->keys[index].data, keybuf, erq->length);	}	priv->tx_key = setindex;	/* Try fast key change if connected and only keys are changed */	if (priv->wep_on && enable && (priv->wep_restrict == restricted) &&	    netif_carrier_ok(dev)) {		err = __orinoco_hw_setup_wepkeys(priv);		/* No need to commit if successful */		goto out;	}	priv->wep_on = enable;	priv->wep_restrict = restricted; out:	orinoco_unlock(priv, &flags);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/620554e406e3cc01434c658a1e597162d7e56fd6/orinoco.c/buggy/drivers/net/wireless/orinoco.c