Finding the index of a symbol in unsigned char and extracting contents?

It's a leftover from a previous use of payload.

Below a simple code to demonstrate what basically happens in the library

char payload[256] = "12345vag";

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  int cnt = 0;
  while(cnt<5)
  {
    if(Serial.available() > 0)
    {
      payload[cnt]=Serial.read();
      cnt++;
    }
  }
  Serial.println(payload);
}

A 256 byte payload buffer, initially filled with 12345vag. A while loop that reads data; in this case exactly 5 characters from serial monitor (set serial monitor up not to send line endings).

Enter some text in the serial monitor (e.g. 56789); the 5 received characters will overwrite the first part of the payload but not the rest. The result is 56789vag.