linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3 RESEND] libertas: check bounds and only use decimal for sysfs persistent features.
@ 2008-07-21 18:04 Brian Cavagnolo
  2008-07-27 15:10 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Cavagnolo @ 2008-07-21 18:04 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, libertas-dev

Some persistent settings were using hex and others decimal.  In some cases,
values were set in hex but reported in decimal.  Confusing.

Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
---
 drivers/net/wireless/libertas/persistcfg.c |   30 ++++++++++++++--------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c
index 6d0ff8d..3309a9c 100644
--- a/drivers/net/wireless/libertas/persistcfg.c
+++ b/drivers/net/wireless/libertas/persistcfg.c
@@ -48,7 +48,7 @@ static ssize_t bootflag_get(struct device *dev,
 	if (ret)
 		return ret;
 
-	return snprintf(buf, 12, "0x%x\n", le32_to_cpu(defs.bootflag));
+	return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag));
 }
 
 /**
@@ -63,8 +63,8 @@ static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%x", &datum);
-	if (ret != 1)
+	ret = sscanf(buf, "%d", &datum);
+	if ((ret != 1) || (datum > 1))
 		return -EINVAL;
 
 	*((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum);
@@ -91,7 +91,7 @@ static ssize_t boottime_get(struct device *dev,
 	if (ret)
 		return ret;
 
-	return snprintf(buf, 12, "0x%x\n", defs.boottime);
+	return snprintf(buf, 12, "%d\n", defs.boottime);
 }
 
 /**
@@ -106,8 +106,8 @@ static ssize_t boottime_set(struct device *dev,
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%x", &datum);
-	if (ret != 1)
+	ret = sscanf(buf, "%d", &datum);
+	if ((ret != 1) || (datum > 255))
 		return -EINVAL;
 
 	/* A too small boot time will result in the device booting into
@@ -143,7 +143,7 @@ static ssize_t channel_get(struct device *dev,
 	if (ret)
 		return ret;
 
-	return snprintf(buf, 12, "0x%x\n", le16_to_cpu(defs.channel));
+	return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel));
 }
 
 /**
@@ -154,11 +154,11 @@ static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
 {
 	struct lbs_private *priv = to_net_dev(dev)->priv;
 	struct cmd_ds_mesh_config cmd;
-	uint16_t datum;
+	uint32_t datum;
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%hx", &datum);
+	ret = sscanf(buf, "%d", &datum);
 	if (ret != 1 || datum < 1 || datum > 11)
 		return -EINVAL;
 
@@ -274,8 +274,8 @@ static ssize_t protocol_id_set(struct device *dev,
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%x", &datum);
-	if (ret != 1)
+	ret = sscanf(buf, "%d", &datum);
+	if ((ret != 1) || (datum > 255))
 		return -EINVAL;
 
 	/* fetch all other Information Element parameters */
@@ -328,8 +328,8 @@ static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%x", &datum);
-	if (ret != 1)
+	ret = sscanf(buf, "%d", &datum);
+	if ((ret != 1) || (datum > 255))
 		return -EINVAL;
 
 	/* fetch all other Information Element parameters */
@@ -382,8 +382,8 @@ static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
 	int ret;
 
 	memset(&cmd, 0, sizeof(cmd));
-	ret = sscanf(buf, "%x", &datum);
-	if (ret != 1)
+	ret = sscanf(buf, "%d", &datum);
+	if ((ret != 1) || (datum > 255))
 		return -EINVAL;
 
 	/* fetch all other Information Element parameters */
-- 
1.5.5.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3 RESEND] libertas: check bounds and only use decimal for sysfs persistent features.
  2008-07-21 18:04 [PATCH 3/3 RESEND] libertas: check bounds and only use decimal for sysfs persistent features Brian Cavagnolo
@ 2008-07-27 15:10 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2008-07-27 15:10 UTC (permalink / raw)
  To: Brian Cavagnolo; +Cc: linville, linux-wireless, libertas-dev

On Mon, 2008-07-21 at 11:04 -0700, Brian Cavagnolo wrote:
> Some persistent settings were using hex and others decimal.  In some cases,
> values were set in hex but reported in decimal.  Confusing.
> 
> Signed-off-by: Brian Cavagnolo <brian@cozybit.com>

Acked-by: Dan Williams <dcbw@redhat.com>

> ---
>  drivers/net/wireless/libertas/persistcfg.c |   30 ++++++++++++++--------------
>  1 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c
> index 6d0ff8d..3309a9c 100644
> --- a/drivers/net/wireless/libertas/persistcfg.c
> +++ b/drivers/net/wireless/libertas/persistcfg.c
> @@ -48,7 +48,7 @@ static ssize_t bootflag_get(struct device *dev,
>  	if (ret)
>  		return ret;
>  
> -	return snprintf(buf, 12, "0x%x\n", le32_to_cpu(defs.bootflag));
> +	return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag));
>  }
>  
>  /**
> @@ -63,8 +63,8 @@ static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%x", &datum);
> -	if (ret != 1)
> +	ret = sscanf(buf, "%d", &datum);
> +	if ((ret != 1) || (datum > 1))
>  		return -EINVAL;
>  
>  	*((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum);
> @@ -91,7 +91,7 @@ static ssize_t boottime_get(struct device *dev,
>  	if (ret)
>  		return ret;
>  
> -	return snprintf(buf, 12, "0x%x\n", defs.boottime);
> +	return snprintf(buf, 12, "%d\n", defs.boottime);
>  }
>  
>  /**
> @@ -106,8 +106,8 @@ static ssize_t boottime_set(struct device *dev,
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%x", &datum);
> -	if (ret != 1)
> +	ret = sscanf(buf, "%d", &datum);
> +	if ((ret != 1) || (datum > 255))
>  		return -EINVAL;
>  
>  	/* A too small boot time will result in the device booting into
> @@ -143,7 +143,7 @@ static ssize_t channel_get(struct device *dev,
>  	if (ret)
>  		return ret;
>  
> -	return snprintf(buf, 12, "0x%x\n", le16_to_cpu(defs.channel));
> +	return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel));
>  }
>  
>  /**
> @@ -154,11 +154,11 @@ static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
>  {
>  	struct lbs_private *priv = to_net_dev(dev)->priv;
>  	struct cmd_ds_mesh_config cmd;
> -	uint16_t datum;
> +	uint32_t datum;
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%hx", &datum);
> +	ret = sscanf(buf, "%d", &datum);
>  	if (ret != 1 || datum < 1 || datum > 11)
>  		return -EINVAL;
>  
> @@ -274,8 +274,8 @@ static ssize_t protocol_id_set(struct device *dev,
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%x", &datum);
> -	if (ret != 1)
> +	ret = sscanf(buf, "%d", &datum);
> +	if ((ret != 1) || (datum > 255))
>  		return -EINVAL;
>  
>  	/* fetch all other Information Element parameters */
> @@ -328,8 +328,8 @@ static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%x", &datum);
> -	if (ret != 1)
> +	ret = sscanf(buf, "%d", &datum);
> +	if ((ret != 1) || (datum > 255))
>  		return -EINVAL;
>  
>  	/* fetch all other Information Element parameters */
> @@ -382,8 +382,8 @@ static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
>  	int ret;
>  
>  	memset(&cmd, 0, sizeof(cmd));
> -	ret = sscanf(buf, "%x", &datum);
> -	if (ret != 1)
> +	ret = sscanf(buf, "%d", &datum);
> +	if ((ret != 1) || (datum > 255))
>  		return -EINVAL;
>  
>  	/* fetch all other Information Element parameters */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-27 15:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-21 18:04 [PATCH 3/3 RESEND] libertas: check bounds and only use decimal for sysfs persistent features Brian Cavagnolo
2008-07-27 15:10 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).