Skip to content

Firmware, out-of-bound reads in the ALARMS case #369

@Yhya99

Description

@Yhya99

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

there's no bound for the char D which will print out bound Level

Describe the solution you'd like
A clear and concise description of what you want to happen.

Add bounds check for character D to be in the bound characters for example from '0' to '6'

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.
Reference from GPAD_HAL.cpp

case Command::ALARM:
  {
    // In the case of an alarm state, the rest of the buffer is a message.
    // we will read up to 60 characters from this buffer for display on our
    // Arguably when we support mulitple states this will become more complicated.
    char D = buf[1]; 
    int N = D - '0';
    serialport->println(N);
    // WARNING: Shouldn't this be MAX_BUFFER_SIZE?
    char msg[61];
    msg[0] = '\0';
    strncat(msg, buf, 60);
    // This copy loooks uncessary, but is not...we want "alarm"
    // to be a completely independent and abstract function.
    // it should copy the msg buffer
    serialport->print("The MQTT Alarm Message: ");
    serialport->println(msg);
    alarm((AlarmLevel)N, msg, serialport); // Makes Lamps indicate alarm.

    break;
  }

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