aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJames Ketrenos <jketreno@linux.intel.com>2005-09-13 18:42:53 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-09-16 03:11:58 -0400
commit262d8e467710a1c870717bc432caaf74cde3ce20 (patch)
tree17ce405907e553bdb8691a60df3d4805461bec72 /net
parent18294d8727b825eb2f3f98d6b6ae4a999dff854a (diff)
[PATCH] ieee80211 Switched to sscanf in store_debug_level
Switched to sscanf as per friendly comment in store_debug_level. Signed-off-by: James Ketrenos <jketreno@linux.intel.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'net')
-rw-r--r--net/ieee80211/ieee80211_module.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 03a47343ddc7..4b43ae1235f9 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -195,34 +195,20 @@ static int show_debug_level(char *page, char **start, off_t offset,
195static int store_debug_level(struct file *file, const char __user * buffer, 195static int store_debug_level(struct file *file, const char __user * buffer,
196 unsigned long count, void *data) 196 unsigned long count, void *data)
197{ 197{
198 char buf[] = "0x00000000"; 198 char buf[] = "0x00000000\n";
199 char *p = (char *)buf; 199 unsigned long len = min((unsigned long)sizeof(buf) - 1, count);
200 unsigned long val; 200 unsigned long val;
201 201
202 if (count > sizeof(buf) - 1) 202 if (copy_from_user(buf, buffer, len))
203 count = sizeof(buf) - 1;
204
205 if (copy_from_user(buf, buffer, count))
206 return count; 203 return count;
207 buf[count] = 0; 204 buf[len] = 0;
208 /* 205 if (sscanf(buf, "%li", &val) != 1)
209 * what a FPOS... What, sscanf(buf, "%i", &val) would be too
210 * scary?
211 */
212 if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
213 p++;
214 if (p[0] == 'x' || p[0] == 'X')
215 p++;
216 val = simple_strtoul(p, &p, 16);
217 } else
218 val = simple_strtoul(p, &p, 10);
219 if (p == buf)
220 printk(KERN_INFO DRV_NAME 206 printk(KERN_INFO DRV_NAME
221 ": %s is not in hex or decimal form.\n", buf); 207 ": %s is not in hex or decimal form.\n", buf);
222 else 208 else
223 ieee80211_debug_level = val; 209 ieee80211_debug_level = val;
224 210
225 return strlen(buf); 211 return strnlen(buf, len);
226} 212}
227 213
228static int __init ieee80211_init(void) 214static int __init ieee80211_init(void)