diff options
author | Frank Pavlic <fpavlic@de.ibm.com> | 2005-11-10 07:49:02 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-11 08:26:21 -0500 |
commit | bd389b9059d8ba4edc563e77f71909d88e566b2d (patch) | |
tree | af985cd4bad8ae19ab4fba1f04baaded601dd157 /drivers/s390 | |
parent | 2ecc26b87a2b3e8650d3c7fe3fc85a8c73d5560d (diff) |
[PATCH] s390: synthax checking for VIPA addresses fixed
[patch 1/7] s390: synthax checking for VIPA addresses fixed
From: Peter Tiedemann <ptiedem@de.ibm.com>
- synthax checking for VIPA addresses fixed
Signed-off-by: Frank Pavlic <fpavlic@de.ibm.com>
diffstat:
qeth.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-------------
qeth_sys.c | 6 ++---
2 files changed, 55 insertions(+), 16 deletions(-)
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/net/qeth.h | 65 | ||||
-rw-r--r-- | drivers/s390/net/qeth_sys.c | 6 |
2 files changed, 55 insertions, 16 deletions
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index 38a2441564d7..635044a4a40b 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/trdevice.h> | 8 | #include <linux/trdevice.h> |
9 | #include <linux/etherdevice.h> | 9 | #include <linux/etherdevice.h> |
10 | #include <linux/if_vlan.h> | 10 | #include <linux/if_vlan.h> |
11 | #include <linux/ctype.h> | ||
11 | 12 | ||
12 | #include <net/ipv6.h> | 13 | #include <net/ipv6.h> |
13 | #include <linux/in6.h> | 14 | #include <linux/in6.h> |
@@ -24,7 +25,7 @@ | |||
24 | 25 | ||
25 | #include "qeth_mpc.h" | 26 | #include "qeth_mpc.h" |
26 | 27 | ||
27 | #define VERSION_QETH_H "$Revision: 1.142 $" | 28 | #define VERSION_QETH_H "$Revision: 1.151 $" |
28 | 29 | ||
29 | #ifdef CONFIG_QETH_IPV6 | 30 | #ifdef CONFIG_QETH_IPV6 |
30 | #define QETH_VERSION_IPV6 ":IPv6" | 31 | #define QETH_VERSION_IPV6 ":IPv6" |
@@ -1074,6 +1075,26 @@ qeth_get_qdio_q_format(struct qeth_card *card) | |||
1074 | } | 1075 | } |
1075 | } | 1076 | } |
1076 | 1077 | ||
1078 | static inline int | ||
1079 | qeth_isdigit(char * buf) | ||
1080 | { | ||
1081 | while (*buf) { | ||
1082 | if (!isdigit(*buf++)) | ||
1083 | return 0; | ||
1084 | } | ||
1085 | return 1; | ||
1086 | } | ||
1087 | |||
1088 | static inline int | ||
1089 | qeth_isxdigit(char * buf) | ||
1090 | { | ||
1091 | while (*buf) { | ||
1092 | if (!isxdigit(*buf++)) | ||
1093 | return 0; | ||
1094 | } | ||
1095 | return 1; | ||
1096 | } | ||
1097 | |||
1077 | static inline void | 1098 | static inline void |
1078 | qeth_ipaddr4_to_string(const __u8 *addr, char *buf) | 1099 | qeth_ipaddr4_to_string(const __u8 *addr, char *buf) |
1079 | { | 1100 | { |
@@ -1090,18 +1111,27 @@ qeth_string_to_ipaddr4(const char *buf, __u8 *addr) | |||
1090 | int i; | 1111 | int i; |
1091 | 1112 | ||
1092 | start = buf; | 1113 | start = buf; |
1093 | for (i = 0; i < 3; i++) { | 1114 | for (i = 0; i < 4; i++) { |
1094 | if (!(end = strchr(start, '.'))) | 1115 | if (i == 3) { |
1116 | end = strchr(start,0xa); | ||
1117 | if (end) | ||
1118 | len = end - start; | ||
1119 | else | ||
1120 | len = strlen(start); | ||
1121 | } | ||
1122 | else { | ||
1123 | end = strchr(start, '.'); | ||
1124 | len = end - start; | ||
1125 | } | ||
1126 | if ((len <= 0) || (len > 3)) | ||
1095 | return -EINVAL; | 1127 | return -EINVAL; |
1096 | len = end - start; | ||
1097 | memset(abuf, 0, 4); | 1128 | memset(abuf, 0, 4); |
1098 | strncpy(abuf, start, len); | 1129 | strncpy(abuf, start, len); |
1130 | if (!qeth_isdigit(abuf)) | ||
1131 | return -EINVAL; | ||
1099 | addr[i] = simple_strtoul(abuf, &tmp, 10); | 1132 | addr[i] = simple_strtoul(abuf, &tmp, 10); |
1100 | start = end + 1; | 1133 | start = end + 1; |
1101 | } | 1134 | } |
1102 | memset(abuf, 0, 4); | ||
1103 | strcpy(abuf, start); | ||
1104 | addr[3] = simple_strtoul(abuf, &tmp, 10); | ||
1105 | return 0; | 1135 | return 0; |
1106 | } | 1136 | } |
1107 | 1137 | ||
@@ -1128,18 +1158,27 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr) | |||
1128 | 1158 | ||
1129 | tmp_addr = (u16 *)addr; | 1159 | tmp_addr = (u16 *)addr; |
1130 | start = buf; | 1160 | start = buf; |
1131 | for (i = 0; i < 7; i++) { | 1161 | for (i = 0; i < 8; i++) { |
1132 | if (!(end = strchr(start, ':'))) | 1162 | if (i == 7) { |
1163 | end = strchr(start,0xa); | ||
1164 | if (end) | ||
1165 | len = end - start; | ||
1166 | else | ||
1167 | len = strlen(start); | ||
1168 | } | ||
1169 | else { | ||
1170 | end = strchr(start, ':'); | ||
1171 | len = end - start; | ||
1172 | } | ||
1173 | if ((len <= 0) || (len > 4)) | ||
1133 | return -EINVAL; | 1174 | return -EINVAL; |
1134 | len = end - start; | ||
1135 | memset(abuf, 0, 5); | 1175 | memset(abuf, 0, 5); |
1136 | strncpy(abuf, start, len); | 1176 | strncpy(abuf, start, len); |
1177 | if (!qeth_isxdigit(abuf)) | ||
1178 | return -EINVAL; | ||
1137 | tmp_addr[i] = simple_strtoul(abuf, &tmp, 16); | 1179 | tmp_addr[i] = simple_strtoul(abuf, &tmp, 16); |
1138 | start = end + 1; | 1180 | start = end + 1; |
1139 | } | 1181 | } |
1140 | memset(abuf, 0, 5); | ||
1141 | strcpy(abuf, start); | ||
1142 | tmp_addr[7] = simple_strtoul(abuf, &tmp, 16); | ||
1143 | return 0; | 1182 | return 0; |
1144 | } | 1183 | } |
1145 | 1184 | ||
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c index f91a02db5743..f43adb967318 100644 --- a/drivers/s390/net/qeth_sys.c +++ b/drivers/s390/net/qeth_sys.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.55 $) | 3 | * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.58 $) |
4 | * | 4 | * |
5 | * Linux on zSeries OSA Express and HiperSockets support | 5 | * Linux on zSeries OSA Express and HiperSockets support |
6 | * This file contains code related to sysfs. | 6 | * This file contains code related to sysfs. |
@@ -20,7 +20,7 @@ | |||
20 | #include "qeth_mpc.h" | 20 | #include "qeth_mpc.h" |
21 | #include "qeth_fs.h" | 21 | #include "qeth_fs.h" |
22 | 22 | ||
23 | const char *VERSION_QETH_SYS_C = "$Revision: 1.55 $"; | 23 | const char *VERSION_QETH_SYS_C = "$Revision: 1.58 $"; |
24 | 24 | ||
25 | /*****************************************************************************/ | 25 | /*****************************************************************************/ |
26 | /* */ | 26 | /* */ |
@@ -1117,7 +1117,7 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | |||
1117 | start = buf; | 1117 | start = buf; |
1118 | /* get address string */ | 1118 | /* get address string */ |
1119 | end = strchr(start, '/'); | 1119 | end = strchr(start, '/'); |
1120 | if (!end){ | 1120 | if (!end || (end-start >= 49)){ |
1121 | PRINT_WARN("Invalid format for ipato_addx/delx. " | 1121 | PRINT_WARN("Invalid format for ipato_addx/delx. " |
1122 | "Use <ip addr>/<mask bits>\n"); | 1122 | "Use <ip addr>/<mask bits>\n"); |
1123 | return -EINVAL; | 1123 | return -EINVAL; |