aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 09e71241265d..4ec5c80e8a7c 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -49,21 +49,6 @@ struct tipc_bearer tipc_bearers[MAX_BEARERS];
49static void bearer_disable(struct tipc_bearer *b_ptr); 49static void bearer_disable(struct tipc_bearer *b_ptr);
50 50
51/** 51/**
52 * media_name_valid - validate media name
53 *
54 * Returns 1 if media name is valid, otherwise 0.
55 */
56static int media_name_valid(const char *name)
57{
58 u32 len;
59
60 len = strlen(name);
61 if ((len + 1) > TIPC_MAX_MEDIA_NAME)
62 return 0;
63 return strspn(name, tipc_alphabet) == len;
64}
65
66/**
67 * tipc_media_find - locates specified media object by name 52 * tipc_media_find - locates specified media object by name
68 */ 53 */
69struct tipc_media *tipc_media_find(const char *name) 54struct tipc_media *tipc_media_find(const char *name)
@@ -102,7 +87,7 @@ int tipc_register_media(struct tipc_media *m_ptr)
102 87
103 write_lock_bh(&tipc_net_lock); 88 write_lock_bh(&tipc_net_lock);
104 89
105 if (!media_name_valid(m_ptr->name)) 90 if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
106 goto exit; 91 goto exit;
107 if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) || 92 if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
108 !m_ptr->bcast_addr.broadcast) 93 !m_ptr->bcast_addr.broadcast)
@@ -206,9 +191,7 @@ static int bearer_name_validate(const char *name,
206 191
207 /* validate component parts of bearer name */ 192 /* validate component parts of bearer name */
208 if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) || 193 if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
209 (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) || 194 (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME))
210 (strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
211 (strspn(if_name, tipc_alphabet) != (if_len - 1)))
212 return 0; 195 return 0;
213 196
214 /* return bearer name components, if necessary */ 197 /* return bearer name components, if necessary */