diff options
author | Frank Pavlic <fpavlic@de.ibm.com> | 2006-09-15 10:26:07 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-17 01:03:07 -0400 |
commit | 1fda1a120b7dcddf382ad105b4783a69e81c7a2b (patch) | |
tree | 46da9fa7105ca5594d94d55ec47e2a7dac7302e7 /drivers | |
parent | 330b636908b44e73c714fb2632602ddd96f72c01 (diff) |
[PATCH] s390: qeth driver fixes [2/6]
[PATCH 5/9] s390: qeth driver fixes [2/6]
From: Frank Pavlic <fpavlic@de.ibm.com>
- fixed error handling in create_device_attributes
- fixed some minor bugs in IPv4
and IPv6 address checking
Signed-off-by: Frank Pavlic <fpavlic@de.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/s390/net/qeth.h | 25 | ||||
-rw-r--r-- | drivers/s390/net/qeth_sys.c | 22 |
2 files changed, 32 insertions, 15 deletions
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index 619f4a0c7160..e8bd8c5ced1f 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h | |||
@@ -1096,10 +1096,11 @@ qeth_string_to_ipaddr4(const char *buf, __u8 *addr) | |||
1096 | { | 1096 | { |
1097 | int count = 0, rc = 0; | 1097 | int count = 0, rc = 0; |
1098 | int in[4]; | 1098 | int in[4]; |
1099 | char c; | ||
1099 | 1100 | ||
1100 | rc = sscanf(buf, "%d.%d.%d.%d%n", | 1101 | rc = sscanf(buf, "%u.%u.%u.%u%c", |
1101 | &in[0], &in[1], &in[2], &in[3], &count); | 1102 | &in[0], &in[1], &in[2], &in[3], &c); |
1102 | if (rc != 4 || count<=0) | 1103 | if (rc != 4 && (rc != 5 || c != '\n')) |
1103 | return -EINVAL; | 1104 | return -EINVAL; |
1104 | for (count = 0; count < 4; count++) { | 1105 | for (count = 0; count < 4; count++) { |
1105 | if (in[count] > 255) | 1106 | if (in[count] > 255) |
@@ -1123,24 +1124,28 @@ qeth_ipaddr6_to_string(const __u8 *addr, char *buf) | |||
1123 | static inline int | 1124 | static inline int |
1124 | qeth_string_to_ipaddr6(const char *buf, __u8 *addr) | 1125 | qeth_string_to_ipaddr6(const char *buf, __u8 *addr) |
1125 | { | 1126 | { |
1126 | char *end, *start; | 1127 | const char *end, *end_tmp, *start; |
1127 | __u16 *in; | 1128 | __u16 *in; |
1128 | char num[5]; | 1129 | char num[5]; |
1129 | int num2, cnt, out, found, save_cnt; | 1130 | int num2, cnt, out, found, save_cnt; |
1130 | unsigned short in_tmp[8] = {0, }; | 1131 | unsigned short in_tmp[8] = {0, }; |
1131 | 1132 | ||
1132 | cnt = out = found = save_cnt = num2 = 0; | 1133 | cnt = out = found = save_cnt = num2 = 0; |
1133 | end = start = (char *) buf; | 1134 | end = start = buf; |
1134 | in = (__u16 *) addr; | 1135 | in = (__u16 *) addr; |
1135 | memset(in, 0, 16); | 1136 | memset(in, 0, 16); |
1136 | while (end) { | 1137 | while (*end) { |
1137 | end = strchr(end,':'); | 1138 | end = strchr(start,':'); |
1138 | if (end == NULL) { | 1139 | if (end == NULL) { |
1139 | end = (char *)buf + (strlen(buf)); | 1140 | end = buf + strlen(buf); |
1140 | out = 1; | 1141 | if ((end_tmp = strchr(start, '\n')) != NULL) |
1142 | end = end_tmp; | ||
1143 | out = 1; | ||
1141 | } | 1144 | } |
1142 | if ((end - start)) { | 1145 | if ((end - start)) { |
1143 | memset(num, 0, 5); | 1146 | memset(num, 0, 5); |
1147 | if ((end - start) > 4) | ||
1148 | return -EINVAL; | ||
1144 | memcpy(num, start, end - start); | 1149 | memcpy(num, start, end - start); |
1145 | if (!qeth_isxdigit(num)) | 1150 | if (!qeth_isxdigit(num)) |
1146 | return -EINVAL; | 1151 | return -EINVAL; |
@@ -1158,6 +1163,8 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr) | |||
1158 | } | 1163 | } |
1159 | start = ++end; | 1164 | start = ++end; |
1160 | } | 1165 | } |
1166 | if (cnt + save_cnt > 8) | ||
1167 | return -EINVAL; | ||
1161 | cnt = 7; | 1168 | cnt = 7; |
1162 | while (save_cnt) | 1169 | while (save_cnt) |
1163 | in[cnt--] = in_tmp[--save_cnt]; | 1170 | in[cnt--] = in_tmp[--save_cnt]; |
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c index 001497bbea16..c1f3187f37ea 100644 --- a/drivers/s390/net/qeth_sys.c +++ b/drivers/s390/net/qeth_sys.c | |||
@@ -1110,12 +1110,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | |||
1110 | { | 1110 | { |
1111 | const char *start, *end; | 1111 | const char *start, *end; |
1112 | char *tmp; | 1112 | char *tmp; |
1113 | char buffer[49] = {0, }; | 1113 | char buffer[40] = {0, }; |
1114 | 1114 | ||
1115 | start = buf; | 1115 | start = buf; |
1116 | /* get address string */ | 1116 | /* get address string */ |
1117 | end = strchr(start, '/'); | 1117 | end = strchr(start, '/'); |
1118 | if (!end || (end-start >= 49)){ | 1118 | if (!end || (end - start >= 40)){ |
1119 | PRINT_WARN("Invalid format for ipato_addx/delx. " | 1119 | PRINT_WARN("Invalid format for ipato_addx/delx. " |
1120 | "Use <ip addr>/<mask bits>\n"); | 1120 | "Use <ip addr>/<mask bits>\n"); |
1121 | return -EINVAL; | 1121 | return -EINVAL; |
@@ -1127,7 +1127,12 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | |||
1127 | } | 1127 | } |
1128 | start = end + 1; | 1128 | start = end + 1; |
1129 | *mask_bits = simple_strtoul(start, &tmp, 10); | 1129 | *mask_bits = simple_strtoul(start, &tmp, 10); |
1130 | 1130 | if (!strlen(start) || | |
1131 | (tmp == start) || | ||
1132 | (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) { | ||
1133 | PRINT_WARN("Invalid mask bits for ipato_addx/delx !\n"); | ||
1134 | return -EINVAL; | ||
1135 | } | ||
1131 | return 0; | 1136 | return 0; |
1132 | } | 1137 | } |
1133 | 1138 | ||
@@ -1698,11 +1703,16 @@ qeth_create_device_attributes(struct device *dev) | |||
1698 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | 1703 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); |
1699 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | 1704 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); |
1700 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | 1705 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); |
1706 | return ret; | ||
1701 | } | 1707 | } |
1702 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))) | 1708 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))){ |
1709 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1710 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | ||
1711 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | ||
1712 | sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group); | ||
1703 | return ret; | 1713 | return ret; |
1704 | 1714 | } | |
1705 | return ret; | 1715 | return 0; |
1706 | } | 1716 | } |
1707 | 1717 | ||
1708 | void | 1718 | void |