aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-07-03 14:01:39 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-07-07 10:11:35 +0200
commit4f30f785c83b164d5603293150653b02dc6c69d8 (patch)
treeb7e2556a447d654b3ed02aabd4bb010241208a40
parentcbb7b79e19f149de5543d3f49c73bc707cd545b9 (diff)
vty: Check returncode of osmo_ss7_pointcode_parse()
The result of osmo_ss7_pointcode_parse() is currently not checked. This means that -EINVAL could end up as value in the pointcode configuration. Check the return code of osmo_ss7_pointcode_parse() and exit the VTY command with CMD_WARNING if the returned pointcode is < 0 Change-Id: Iae6d92b1d135063dfd0a26bc23a89802cb3b1a78
-rw-r--r--src/osmo_ss7_vty.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 8e40474..b06f554 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -165,7 +165,11 @@ DEFUN(cs7_point_code, cs7_point_code_cmd,
"Point Code\n")
{
struct osmo_ss7_instance *inst = vty->index;
- uint32_t pc = osmo_ss7_pointcode_parse(inst, argv[0]);
+ int pc = osmo_ss7_pointcode_parse(inst, argv[0]);
+ if (pc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
inst->cfg.primary_pc = pc;
return CMD_SUCCESS;
@@ -271,11 +275,21 @@ DEFUN(cs7_rt_upd, cs7_rt_upd_cmd,
{
struct osmo_ss7_route_table *rtable = vty->index;
struct osmo_ss7_route *rt;
- uint32_t dpc = osmo_ss7_pointcode_parse(rtable->inst, argv[0]);
- uint32_t mask = osmo_ss7_pointcode_parse_mask_or_len(rtable->inst, argv[1]);
+ int dpc = osmo_ss7_pointcode_parse(rtable->inst, argv[0]);
+ int mask = osmo_ss7_pointcode_parse_mask_or_len(rtable->inst, argv[1]);
const char *ls_name = argv[2];
unsigned int argind;
+ if (dpc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (mask < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
rt = osmo_ss7_route_create(rtable, dpc, mask, ls_name);
if (!rt) {
vty_out(vty, "cannot create route %s/%s to %s%s",
@@ -307,8 +321,18 @@ DEFUN(cs7_rt_rem, cs7_rt_rem_cmd,
{
struct osmo_ss7_route_table *rtable = vty->index;
struct osmo_ss7_route *rt;
- uint32_t dpc = osmo_ss7_pointcode_parse(rtable->inst, argv[0]);
- uint32_t mask = osmo_ss7_pointcode_parse_mask_or_len(rtable->inst, argv[1]);
+ int dpc = osmo_ss7_pointcode_parse(rtable->inst, argv[0]);
+ int mask = osmo_ss7_pointcode_parse_mask_or_len(rtable->inst, argv[1]);
+
+ if (dpc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (mask < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
rt = osmo_ss7_route_find_dpc_mask(rtable, dpc, mask);
if (!rt) {
@@ -770,9 +794,16 @@ DEFUN(as_rout_key, as_rout_key_cmd,
struct osmo_ss7_as *as = vty->index;
struct osmo_ss7_routing_key *rkey = &as->cfg.routing_key;
int argind;
+ int pc;
+
+ pc = osmo_ss7_pointcode_parse(as->inst, argv[1]);
+ if (pc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ rkey->pc = pc;
rkey->context = atoi(argv[0]);
- rkey->pc = osmo_ss7_pointcode_parse(as->inst, argv[1]);
argind = 2;
if (argind < argc && !strcmp(argv[argind], "si")) {
@@ -799,7 +830,11 @@ DEFUN(as_pc_override, as_pc_override_cmd,
"New Point Code\n")
{
struct osmo_ss7_as *as = vty->index;
- uint32_t pc = osmo_ss7_pointcode_parse(as->inst, argv[0]);
+ int pc = osmo_ss7_pointcode_parse(as->inst, argv[0]);
+ if (pc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
if (as->cfg.proto != OSMO_SS7_ASP_PROT_IPA) {
vty_out(vty, "Only IPA type AS support point-code override. "
@@ -1208,11 +1243,19 @@ DEFUN(cs7_sccpaddr_ri, cs7_sccpaddr_ri_cmd,
DEFUN(cs7_sccpaddr_pc, cs7_sccpaddr_pc_cmd,
"point-code POINT_CODE", "Add point-code Number\n" "PC\n")
{
+ int pc;
struct osmo_sccp_addr_entry *entry =
(struct osmo_sccp_addr_entry *)vty->index;
OSMO_ASSERT(entry);
+
+ pc = osmo_ss7_pointcode_parse(entry->inst, argv[0]);
+ if (pc < 0) {
+ vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
entry->addr.presence |= OSMO_SCCP_ADDR_T_PC;
- entry->addr.pc = osmo_ss7_pointcode_parse(entry->inst, argv[0]);
+ entry->addr.pc = pc;
return CMD_SUCCESS;
}