negative delays and delay int size fixed

This commit is contained in:
Pavel Vorobyov
2020-03-26 12:35:58 +03:00
parent abb8943266
commit 49caf07ba6
2 changed files with 7 additions and 3 deletions

View File

@@ -273,14 +273,18 @@ func (c *Cli) doAlias(name string, argsLine string, args ...string) {
func (c *Cli) doDelay(name string, argsLine string, args ...string) {
if len(args) < 1 {
term.Errorf("Usage: delay <seconds>\n")
term.Warnf("Current delay value: %d\n", c.delay)
return
}
sec, err := strconv.ParseInt(args[0], 10, 8)
sec, err := strconv.ParseInt(args[0], 10, 32)
if err != nil {
term.Errorf("Invalid delay format: %s\n", err)
return
}
if sec < 0 {
term.Errorf("Invalid delay format: delay can't be negative\n")
return
}
c.delay = int(sec)
}

View File

@@ -224,7 +224,7 @@ func read(filename string, secondPass bool) (*XCConfig, error) {
cfg.SSHConnectTimeout = ctimeout
delay, err := props.GetInt("executer.delay")
if err != nil {
if err != nil || delay < 0 {
delay = defaultDelay
}
cfg.Delay = delay