OLD | NEW |
1 /* | 1 /* |
2 * This file implement the Wireless Extensions core API. | 2 * This file implement the Wireless Extensions core API. |
3 * | 3 * |
4 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> | 4 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> |
5 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. | 5 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. |
6 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> | 6 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> |
7 * | 7 * |
8 * (As all part of the Linux kernel, this file is GPL) | 8 * (As all part of the Linux kernel, this file is GPL) |
9 */ | 9 */ |
10 #include <linux/kernel.h> | 10 #include <linux/kernel.h> |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 } | 808 } |
809 | 809 |
810 if (cmd == SIOCSIWENCODEEXT) { | 810 if (cmd == SIOCSIWENCODEEXT) { |
811 struct iw_encode_ext *ee = (void *) extra; | 811 struct iw_encode_ext *ee = (void *) extra; |
812 | 812 |
813 if (iwp->length < sizeof(*ee) + ee->key_len) | 813 if (iwp->length < sizeof(*ee) + ee->key_len) |
814 return -EFAULT; | 814 return -EFAULT; |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
| 818 if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) { |
| 819 /* |
| 820 * If this is a GET, but not NOMAX, it means that the extra |
| 821 * data is not bounded by userspace, but by max_tokens. Thus |
| 822 * set the length to max_tokens. This matches the extra data |
| 823 * allocation. |
| 824 * The driver should fill it with the number of tokens it |
| 825 * provided, and it may check iwp->length rather than having |
| 826 * knowledge of max_tokens. If the driver doesn't change the |
| 827 * iwp->length, this ioctl just copies back max_token tokens |
| 828 * filled with zeroes. Hopefully the driver isn't claiming |
| 829 * them to be valid data. |
| 830 */ |
| 831 iwp->length = descr->max_tokens; |
| 832 } |
| 833 |
818 err = handler(dev, info, (union iwreq_data *) iwp, extra); | 834 err = handler(dev, info, (union iwreq_data *) iwp, extra); |
819 | 835 |
820 iwp->length += essid_compat; | 836 iwp->length += essid_compat; |
821 | 837 |
822 /* If we have something to return to the user */ | 838 /* If we have something to return to the user */ |
823 if (!err && IW_IS_GET(cmd)) { | 839 if (!err && IW_IS_GET(cmd)) { |
824 /* Check if there is enough buffer up there */ | 840 /* Check if there is enough buffer up there */ |
825 if (user_length < iwp->length) { | 841 if (user_length < iwp->length) { |
826 err = -E2BIG; | 842 err = -E2BIG; |
827 goto out; | 843 goto out; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 compat_private_call); | 1111 compat_private_call); |
1096 | 1112 |
1097 if (ret >= 0 && | 1113 if (ret >= 0 && |
1098 IW_IS_GET(cmd) && | 1114 IW_IS_GET(cmd) && |
1099 copy_to_user(argp, &iwr, sizeof(struct iwreq))) | 1115 copy_to_user(argp, &iwr, sizeof(struct iwreq))) |
1100 return -EFAULT; | 1116 return -EFAULT; |
1101 | 1117 |
1102 return ret; | 1118 return ret; |
1103 } | 1119 } |
1104 #endif | 1120 #endif |
OLD | NEW |