diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-21 08:50:28 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-21 08:50:28 (GMT) |
commit | a82af17b7242d0ee3794f8252fe0b4375a4b1e72 (patch) | |
tree | 4bfe68dc36e7ef8fda2ad9fde552b520ae0de38a /src/helsinki.at/rhimport | |
parent | b3a4b4f49597aae618f374347117cfa762c5fd9a (diff) |
improved sanity checks for importcontext and telnet interface
Diffstat (limited to 'src/helsinki.at/rhimport')
-rw-r--r-- | src/helsinki.at/rhimport/importer.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go index 9be1257..df491d7 100644 --- a/src/helsinki.at/rhimport/importer.go +++ b/src/helsinki.at/rhimport/importer.go @@ -35,6 +35,11 @@ import ( "path" ) +const ( + CART_MAX = 999999 + CUT_MAX = 999 +) + var ( bool2str = map[bool]string{false: "0", true: "1"} ) @@ -100,6 +105,12 @@ func (ctx *ImportContext) SanityCheck() error { return fmt.Errorf("empty Password on untrusted control interface is not allowed") } if ctx.ShowId != 0 { + if ctx.ShowId != 0 && ctx.ShowId > CART_MAX { + return fmt.Errorf("ShowId %d is outside of allowed range (0 < show-id < %d)", ctx.ShowId, CART_MAX) + } + if ctx.Cart != 0 && ctx.Cart > CART_MAX { + return fmt.Errorf("Cart %d is outside of allowed range (0 < cart < %d)", ctx.Cart, CART_MAX) + } return nil } if ctx.GroupName != "" { @@ -118,6 +129,12 @@ func (ctx *ImportContext) SanityCheck() error { if ctx.Cart == 0 { return fmt.Errorf("either ShowId, PoolName or CartNumber must be supplied") } + if ctx.Cart > CART_MAX { + return fmt.Errorf("Cart %d is outside of allowed range (0 < cart < %d)", ctx.Cart, CART_MAX) + } + if ctx.Cut != 0 && ctx.Cut > CUT_MAX { + return fmt.Errorf("Cut %d is outside of allowed range (0 < cart < %d)", ctx.Cut, CUT_MAX) + } if ctx.Channels != 1 && ctx.Channels != 2 { return fmt.Errorf("channles must be 1 or 2") } |