Array of 3 chars becomes array of multiple chars!

I’m going crazy with this!
The code that is giving me a headache is:

if (radio.receiveDone())
  {
    char receivedMSG[radio.DATALEN] = "";
    
    byte newStatus=STATUS;
    boolean reportStatusRequest=false;
    DEBUG('[');DEBUG(radio.SENDERID);DEBUG("] ");
    for (byte i = 0; i < radio.DATALEN; i++){
      receivedMSG[i] = radio.DATA[i];
      //DEBUG((char)radio.DATA[i]);
      //Serial.println(i);
      //Serial.print("-");
      Serial.print(receivedMSG[i]);
    }
    Serial.println();

    char deviceIDChr[3] = "";
    char deviceStatusChr[3] = "000";
    char deviceTimerChr[8] = "";
    char charStatus[7] = { "status" };
    char charStatusUPPER[7] = { "STATUS" };
    char charTimer[5] = { "timer" };
    char charTimerUPPER[5] = { "TIMER" };
    byte i = 0;
    byte k = 0;
    byte lengthID = 0;
    byte lengthStatus = 0;
    byte lengthTimer = 0;
    
    if ( (receivedMSG[0] == 'I') && (receivedMSG[1] == 'D') ){
      i = 3;
      while (receivedMSG[i] != ',' && i < radio.DATALEN){
        deviceIDChr[k] = receivedMSG[i];
        lengthID++;
        i++;
        k++;
      }
      i++;
      k = 0;
      while (i < radio.DATALEN && (receivedMSG[i] == charStatus[k] || receivedMSG[i] == charStatusUPPER[k]) ){
        i++;
        k++;
      }
      i++;
      k = 0;
      Serial.print("i = "); Serial.println(i);
      while (receivedMSG[i] != ',' && i < radio.DATALEN){
        Serial.print("i = ");
        Serial.print(i);
        Serial.print("receivedMSG[i]");
        Serial.println(receivedMSG[i]);
        deviceStatusChr[k] = receivedMSG[i];
        lengthStatus++;
        i++;
        k++;
      }
      i++;
      k = 0;
      while (i < radio.DATALEN && (receivedMSG[i] == charTimer[k] || receivedMSG[i] == charTimerUPPER[k]) ){
        i++;
        k++;
      }
      i++;
      k = 0;
      while (receivedMSG[i] != ',' && i < radio.DATALEN){
        deviceTimerChr[k] = receivedMSG[i];
        lengthTimer++;
        i++;
        k++;
      }
    }
    Serial.print("Message split: ");
    Serial.print("ID:");
    //for(byte i=0; i < lengthID; i++){
      //Serial.print(deviceIDChr[i]);
    //}
    deviceID = atoi(deviceIDChr);
    Serial.print(deviceID);
    Serial.print(" - status:");
    
    for(byte i=0; i < lengthStatus; i++)
      Serial.print(deviceStatusChr[i]);
      
    //deviceStatus = atoi(deviceStatusChr);
    //sscanf(deviceStatusChr, "%d", &deviceStatus);
    Serial.print("-");
    Serial.print(deviceStatusChr);
    Serial.print(" - timer:");
    //for(byte i=0; i < lengthTimer; i++)
      //Serial.print(deviceTimerChr[i]);
    deviceTimer = atoi(deviceTimerChr);
    Serial.print(deviceTimer);
    Serial.println();

if the radio received messages is “ID:149,status:123,timer:1200”
The var deviceStatusChr that should be an array of 3, prints out “123149”!
And if I put the deviceStatusChr into global, it actually prints “123ID:149 - STATUS:123-123149 - TIME”.
How is that even possible???
What is the very simple thing that I’m missing?
The whole code is attached.

ProMiniRFM69-Serra.ino (18 KB)

You are probably overflowing character array boundaries, or forgetting to make sure that a zero terminator is present.

Check to see that you have allocated enough space for every possible message (plus one byte for the zero terminator).

Perfect example of incorrect space allocation (it takes 4 characters to store the string “000”):

    char deviceStatusChr[3] = "000";

Wow you've been fast!!! Another thing learned today: zero terminator! Problem solved! Thanksa lot Jremington!