Skip to content

no bounds checking #30

@chrwei

Description

@chrwei

setRGB and rainbow methods have no bounds checking, and also are using inappropriate datatypes for the values.

void qduino::setRGB(int r, int g, int b){ should instead be void qduino::setRGB(uint_8t r, uint_8t g, uint_8t b){ to limit the values to 0-255, which effectively limits it. as int, the 255-r is going to allow negative numbers to be passed to analogWrite. newr should also be uint_8t, and have a constrain() added to the map().

rainbow should be similarly constrained to prevent negative values. as is, a 0 duration would pass -125 delayMicroseconds(). there is also nothing preventing >5, which is fine unless it ends up overflowing the int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions