aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/qeth.h
diff options
context:
space:
mode:
authorFrank Pavlic <fpavlic@de.ibm.com>2006-09-15 10:26:07 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-17 01:03:07 -0400
commit1fda1a120b7dcddf382ad105b4783a69e81c7a2b (patch)
tree46da9fa7105ca5594d94d55ec47e2a7dac7302e7 /drivers/s390/net/qeth.h
parent330b636908b44e73c714fb2632602ddd96f72c01 (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/s390/net/qeth.h')
-rw-r--r--drivers/s390/net/qeth.h25
1 files changed, 16 insertions, 9 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)
1123static inline int 1124static inline int
1124qeth_string_to_ipaddr6(const char *buf, __u8 *addr) 1125qeth_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];