Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Buffer overrun error #6

@MisterMartin

Description

@MisterMartin

In Flight.cc, there is a possible buffer overrun coding error, in the FL_MEASURE case block.

indx can get incremented up to PHA_BUFFER_SIZE-1, and then incremented when used as an index for PHAArray.

It doesn't appear that this incipient bug has appeared in normal testing. indx is printed during operation, and it has always been 1039 or 1040. Seems that it won't happen as long as \n has been received correctly.

The code in question, with just the significant parts retained, is here:

      case FL_MEASURE:
           ...
            while(inByte != '\n' && indx < PHA_BUFFER_SIZE) //Read the data byte by byte until we hit an EOL or timeout
            {
                if(OPCSERIAL.available())
                {
                    ...
                    indx++;
                }
                ...
            }
            if(inByte != '\n')  //if we exited due to a timeout
            {
            ...
            }
            else
            {
                /* Process the PHA Data */
                PHAArray[indx+1] ='\0'; //add a null after the data to end the string
               ...
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions