Ignore:
Timestamp:
Jun 22, 2021, 9:00:19 PM (3 years ago)
Author:
coas-nagasima
Message:

WolfSSLとAzure IoT SDKを更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • azure_iot_hub_f767zi/trunk/azure_iot_sdk/umqtt/src/mqtt_client.c

    r457 r464  
    770770                    /*Codes_SRS_MQTT_CLIENT_07_028: [If the actionResult parameter is of type CONNECT_ACK then the msgInfo value shall be a CONNECT_ACK structure.]*/
    771771                    CONNECT_ACK connack = { 0 };
    772                     connack.isSessionPresent = (byteutil_readByte(&iterator) == 0x1) ? true : false;
     772                    if (packetLength != 2) // CONNACK payload must be only 2 bytes
     773                    {
     774                        LogError("Invalid CONNACK packet.");
     775                        set_error_callback(mqtt_client, MQTT_CLIENT_COMMUNICATION_ERROR);
     776                        break;
     777                    }
     778
     779                    uint8_t connect_acknowledge_flags = byteutil_readByte(&iterator);
     780                    if (connect_acknowledge_flags & 0xFE) // bits 7-1 must be zero
     781                    {
     782                        LogError("Invalid CONNACK packet.");
     783                        set_error_callback(mqtt_client, MQTT_CLIENT_COMMUNICATION_ERROR);
     784                        break;
     785                    }
     786
     787                    connack.isSessionPresent = (connect_acknowledge_flags == 0x1) ? true : false;
    773788                    uint8_t rc = byteutil_readByte(&iterator);
    774789                    connack.returnCode =
     
    802817                case PUBCOMP_TYPE:
    803818                {
     819                    if (packetLength != 2) // PUBXXX payload must be only 2 bytes
     820                    {
     821                        LogError("Invalid packet length.");
     822                        set_error_callback(mqtt_client, MQTT_CLIENT_COMMUNICATION_ERROR);
     823                        break;
     824                    }
     825
    804826                    /*Codes_SRS_MQTT_CLIENT_07_029: [If the actionResult parameter are of types PUBACK_TYPE, PUBREC_TYPE, PUBREL_TYPE or PUBCOMP_TYPE then the msgInfo value shall be a PUBLISH_ACK structure.]*/
    805827                    MQTT_CLIENT_EVENT_RESULT action = (packet == PUBACK_TYPE) ? MQTT_CLIENT_ON_PUBLISH_ACK :
     
    876898                        {
    877899                            uint8_t qosRet = byteutil_readByte(&iterator);
     900                            if (qosRet & 0x7C) // SUBACK QOS bits 6-2 must be zero
     901                            {
     902                                LogError("Invalid SUBACK_TYPE packet.");
     903                                set_error_callback(mqtt_client, MQTT_CLIENT_COMMUNICATION_ERROR);
     904                                break;
     905                            }
    878906                            suback.qosReturn[suback.qosCount++] =
    879907                                (qosRet <= ((uint8_t)DELIVER_EXACTLY_ONCE)) ?
     
    909937                    /*Codes_SRS_MQTT_CLIENT_07_031: [If the actionResult parameter is of type UNSUBACK_TYPE then the msgInfo value shall be a UNSUBSCRIBE_ACK structure.]*/
    910938                    UNSUBSCRIBE_ACK unsuback = { 0 };
     939                    if (packetLength != 2) // UNSUBACK_TYPE payload must be only 2 bytes
     940                    {
     941                        LogError("Invalid UNSUBACK packet length.");
     942                        set_error_callback(mqtt_client, MQTT_CLIENT_COMMUNICATION_ERROR);
     943                        break;
     944                    }
     945
    911946                    unsuback.packetId = byteutil_read_uint16(&iterator, packetLength);
    912947
     
    943978    {
    944979        LogError("recvCompleteCallback context failed.");
     980    }
     981}
     982
     983void mqtt_client_clear_xio(MQTT_CLIENT_HANDLE handle)
     984{
     985    if (handle != NULL)
     986    {
     987        MQTT_CLIENT *mqtt_client = (MQTT_CLIENT *)handle;
     988
     989        // The upstream transport handle allocates and deallocates the xio handle.
     990        // The reference to that xio handle is shared between this layer (mqtt layer)
     991        // and the upstream layer. The clearing done here is to signal to this layer
     992        // that the handle is no longer available to be used. This is different from
     993        // deiniting the mqtt client in that we do not want an entire teardown, but
     994        // only a possible re-upping of the xio in the future.
     995        mqtt_client->xioHandle = NULL;
    945996    }
    946997}
Note: See TracChangeset for help on using the changeset viewer.