String message length



  • In MyMessage.c is length of string message incorrect for longer messages. Right now is:

    MyMessage& MyMessage::set(const char* value) {
    uint8_t length = strlen(value);
    miSetLength(length);
    miSetPayloadType(P_STRING);
    strncpy(data, value, min(length, MAX_PAYLOAD));
    return *this;
    }

    Correct calculation of length is:

    MyMessage& MyMessage::set(const char* value) {
    ** uint8_t length = min(strlen(value), MAX_PAYLOAD);**
    miSetLength(length);
    miSetPayloadType(P_STRING);
    ** strncpy(data, value, length);**
    return *this;
    }

    I have problems in EasyIoT server if gw.sendSketchInfo text is longer than 24 characters. I've added additional checks but it's right to fix problem at source.


    Log in to reply
     

  • Admin

    @EasyIoT said:

    uint8_t length = min(strlen(value), MAX_PAYLOAD);

    Thanks, update pushed.


Log in to reply
 

1 out of 2

Suggested Topics


  • Controllers   9 Aug 2014, 10:44

    33
  • 9

  • Bug Reports   1 Jun 2022, 16:02

    2

  • Bug Reports   3 Mar 2021, 18:48

    11

  • Bug Reports   8 Jul 2021, 11:42

    17
  • 5

0
Online

11.5k
Users

11.1k
Topics

112.8k
Posts