]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] ieee80211_module.c::store_debug_level() cleanup
authorAl Viro <viro@www.linux.org.uk>
Sun, 3 Apr 2005 08:15:52 +0000 (09:15 +0100)
committerJeff Garzik <jgarzik@pobox.com>
Sat, 28 May 2005 02:15:13 +0000 (22:15 -0400)
* trivial __user annotations
* store_debug_level() sanitized a bit
Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
net/ieee80211/ieee80211_module.c

index e4ca0daaaeea966a46bd21bc0c8e120f42aa516a..90bc50b97ea78f9c0b6863724efaec8bd935055f 100644 (file)
@@ -194,17 +194,23 @@ static int show_debug_level(char *page, char **start, off_t offset,
        return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
 }
 
-static int store_debug_level(struct file *file, const char *buffer,
+static int store_debug_level(struct file *file, const char __user *buffer,
                             unsigned long count, void *data)
 {
        char buf[] = "0x00000000";
-       unsigned long len = min(sizeof(buf) - 1, (u32)count);
        char *p = (char *)buf;
        unsigned long val;
 
-       if (copy_from_user(buf, buffer, len))
+       if (count > sizeof(buf) - 1)
+               count = sizeof(buf) - 1;
+
+       if (copy_from_user(buf, buffer, count))
                return count;
-       buf[len] = 0;
+       buf[count] = 0;
+       /*
+        * what a FPOS...  What, sscanf(buf, "%i", &val) would be too
+        * scary?
+        */
        if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
                p++;
                if (p[0] == 'x' || p[0] == 'X')
@@ -218,7 +224,7 @@ static int store_debug_level(struct file *file, const char *buffer,
        else
                ieee80211_debug_level = val;
 
-       return strnlen(buf, count);
+       return strlen(buf);
 }
 
 static int __init ieee80211_init(void)