Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Minimum and maximum values config policy rules for int/floats crash plugins when used #1080

Closed
IRCody opened this issue Jul 15, 2016 · 0 comments
Labels

Comments

@IRCody
Copy link
Contributor

IRCody commented Jul 15, 2016

Adding either

cpolicy.NewIntegerRule("crashes", false, 0, 1, 2) 

or

cpolicy.NewFloatRule("crashes", false, 0, 1, 2)

to a plugins GetConfigPolicy method will cause the plugin to crash on startup. This is because the min/max values are not handled properly here and here. The failing logic for both is:

    options := make([]*int, 1)
    for i, o := range opts {
        options[i] = &o
    }

    return &IntRule{
        key:      key,
        required: req,
        default_: options[0],
    }, nil

This causes a crash because, in the case where len(opts) is greater than 1 (i.e. if a min or max is set), it will cause out of bounds error on options since it's statically size 1. A second issue is that the minimum/maximum are never set in the returned rule.

candysmurf added a commit to candysmurf/snap that referenced this issue Jul 16, 2016
candysmurf added a commit to candysmurf/snap that referenced this issue Jul 16, 2016
candysmurf added a commit that referenced this issue Jul 18, 2016
Fixed #1080 rules for int/floats crash plugins
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant