Skip to content

Commit

Permalink
tipc: remove pointless name sanity check and tipc_alphabet array
Browse files Browse the repository at this point in the history
There is no real reason to check whether all letters in the given
media name and network interface name are within the character set
defined in tipc_alphabet array. Even if we eliminate the checking,
the rest of checking conditions in tipc_enable_bearer() can ensure
we do not enable an invalid or illegal bearer.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ying Xue authored and David S. Miller committed Aug 20, 2012
1 parent 4225a39 commit fc07393
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
6 changes: 2 additions & 4 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int media_name_valid(const char *name)
len = strlen(name);
if ((len + 1) > TIPC_MAX_MEDIA_NAME)
return 0;
return strspn(name, tipc_alphabet) == len;
return 1;
}

/**
Expand Down Expand Up @@ -206,9 +206,7 @@ static int bearer_name_validate(const char *name,

/* validate component parts of bearer name */
if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
(if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) ||
(strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
(strspn(if_name, tipc_alphabet) != (if_len - 1)))
(if_len <= 1) || (if_len > TIPC_MAX_IF_NAME))
return 0;

/* return bearer name components, if necessary */
Expand Down
3 changes: 0 additions & 3 deletions net/tipc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
/* global variables used by multiple sub-systems within TIPC */
int tipc_random;

const char tipc_alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";

/* configurable TIPC parameters */
u32 tipc_own_addr;
int tipc_max_ports;
Expand Down
2 changes: 0 additions & 2 deletions net/tipc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ extern int tipc_remote_management;
* Other global variables
*/
extern int tipc_random;
extern const char tipc_alphabet[];


/*
* Routines available to privileged subsystems
Expand Down
4 changes: 1 addition & 3 deletions net/tipc/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ static int link_name_validate(const char *name,
(z_local > 255) || (c_local > 4095) || (n_local > 4095) ||
(z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) ||
(if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) ||
(if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME) ||
(strspn(if_local, tipc_alphabet) != (if_local_len - 1)) ||
(strspn(if_peer, tipc_alphabet) != (if_peer_len - 1)))
(if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME))
return 0;

/* return link name components, if necessary */
Expand Down

0 comments on commit fc07393

Please sign in to comment.