diff options
Diffstat (limited to 'kernel/sysctl_binary.c')
| -rw-r--r-- | kernel/sysctl_binary.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 10a1d7dc9313..6eb99c17dbd8 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/ctype.h> | 13 | #include <linux/ctype.h> |
| 14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
| 15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
| 16 | #include <linux/uuid.h> | ||
| 16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| 17 | #include <linux/compat.h> | 18 | #include <linux/compat.h> |
| 18 | 19 | ||
| @@ -1117,9 +1118,8 @@ static ssize_t bin_uuid(struct file *file, | |||
| 1117 | 1118 | ||
| 1118 | /* Only supports reads */ | 1119 | /* Only supports reads */ |
| 1119 | if (oldval && oldlen) { | 1120 | if (oldval && oldlen) { |
| 1120 | char buf[40], *str = buf; | 1121 | char buf[UUID_STRING_LEN + 1]; |
| 1121 | unsigned char uuid[16]; | 1122 | uuid_be uuid; |
| 1122 | int i; | ||
| 1123 | 1123 | ||
| 1124 | result = kernel_read(file, 0, buf, sizeof(buf) - 1); | 1124 | result = kernel_read(file, 0, buf, sizeof(buf) - 1); |
| 1125 | if (result < 0) | 1125 | if (result < 0) |
| @@ -1127,24 +1127,15 @@ static ssize_t bin_uuid(struct file *file, | |||
| 1127 | 1127 | ||
| 1128 | buf[result] = '\0'; | 1128 | buf[result] = '\0'; |
| 1129 | 1129 | ||
| 1130 | /* Convert the uuid to from a string to binary */ | 1130 | result = -EIO; |
| 1131 | for (i = 0; i < 16; i++) { | 1131 | if (uuid_be_to_bin(buf, &uuid)) |
| 1132 | result = -EIO; | 1132 | goto out; |
| 1133 | if (!isxdigit(str[0]) || !isxdigit(str[1])) | ||
| 1134 | goto out; | ||
| 1135 | |||
| 1136 | uuid[i] = (hex_to_bin(str[0]) << 4) | | ||
| 1137 | hex_to_bin(str[1]); | ||
| 1138 | str += 2; | ||
| 1139 | if (*str == '-') | ||
| 1140 | str++; | ||
| 1141 | } | ||
| 1142 | 1133 | ||
| 1143 | if (oldlen > 16) | 1134 | if (oldlen > 16) |
| 1144 | oldlen = 16; | 1135 | oldlen = 16; |
| 1145 | 1136 | ||
| 1146 | result = -EFAULT; | 1137 | result = -EFAULT; |
| 1147 | if (copy_to_user(oldval, uuid, oldlen)) | 1138 | if (copy_to_user(oldval, &uuid, oldlen)) |
| 1148 | goto out; | 1139 | goto out; |
| 1149 | 1140 | ||
| 1150 | copied = oldlen; | 1141 | copied = oldlen; |
