Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Frank Pavlic and committed by
Jeff Garzik
1fda1a12 330b6369

+33 -16
+16 -9
drivers/s390/net/qeth.h
··· 1096 1096 { 1097 1097 int count = 0, rc = 0; 1098 1098 int in[4]; 1099 + char c; 1099 1100 1100 - rc = sscanf(buf, "%d.%d.%d.%d%n", 1101 - &in[0], &in[1], &in[2], &in[3], &count); 1102 - if (rc != 4 || count<=0) 1101 + rc = sscanf(buf, "%u.%u.%u.%u%c", 1102 + &in[0], &in[1], &in[2], &in[3], &c); 1103 + if (rc != 4 && (rc != 5 || c != '\n')) 1103 1104 return -EINVAL; 1104 1105 for (count = 0; count < 4; count++) { 1105 1106 if (in[count] > 255) ··· 1124 1123 static inline int 1125 1124 qeth_string_to_ipaddr6(const char *buf, __u8 *addr) 1126 1125 { 1127 - char *end, *start; 1126 + const char *end, *end_tmp, *start; 1128 1127 __u16 *in; 1129 1128 char num[5]; 1130 1129 int num2, cnt, out, found, save_cnt; 1131 1130 unsigned short in_tmp[8] = {0, }; 1132 1131 1133 1132 cnt = out = found = save_cnt = num2 = 0; 1134 - end = start = (char *) buf; 1133 + end = start = buf; 1135 1134 in = (__u16 *) addr; 1136 1135 memset(in, 0, 16); 1137 - while (end) { 1138 - end = strchr(end,':'); 1136 + while (*end) { 1137 + end = strchr(start,':'); 1139 1138 if (end == NULL) { 1140 - end = (char *)buf + (strlen(buf)); 1141 - out = 1; 1139 + end = buf + strlen(buf); 1140 + if ((end_tmp = strchr(start, '\n')) != NULL) 1141 + end = end_tmp; 1142 + out = 1; 1142 1143 } 1143 1144 if ((end - start)) { 1144 1145 memset(num, 0, 5); 1146 + if ((end - start) > 4) 1147 + return -EINVAL; 1145 1148 memcpy(num, start, end - start); 1146 1149 if (!qeth_isxdigit(num)) 1147 1150 return -EINVAL; ··· 1163 1158 } 1164 1159 start = ++end; 1165 1160 } 1161 + if (cnt + save_cnt > 8) 1162 + return -EINVAL; 1166 1163 cnt = 7; 1167 1164 while (save_cnt) 1168 1165 in[cnt--] = in_tmp[--save_cnt];
+17 -7
drivers/s390/net/qeth_sys.c
··· 1110 1110 { 1111 1111 const char *start, *end; 1112 1112 char *tmp; 1113 - char buffer[49] = {0, }; 1113 + char buffer[40] = {0, }; 1114 1114 1115 1115 start = buf; 1116 1116 /* get address string */ 1117 1117 end = strchr(start, '/'); 1118 - if (!end || (end-start >= 49)){ 1118 + if (!end || (end - start >= 40)){ 1119 1119 PRINT_WARN("Invalid format for ipato_addx/delx. " 1120 1120 "Use <ip addr>/<mask bits>\n"); 1121 1121 return -EINVAL; ··· 1127 1127 } 1128 1128 start = end + 1; 1129 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 1136 return 0; 1132 1137 } 1133 1138 ··· 1703 1698 sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 1704 1699 sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); 1705 1700 sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); 1706 - } 1707 - if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))) 1708 1701 return ret; 1709 - 1710 - return ret; 1702 + } 1703 + if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))){ 1704 + sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 1705 + sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); 1706 + sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); 1707 + sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group); 1708 + return ret; 1709 + } 1710 + return 0; 1711 1711 } 1712 1712 1713 1713 void