5ghub / 5G-NB-IoT

13 stars 6 forks source link

String comparison bugs #2

Open maxgerhardt opened 2 years ago

maxgerhardt commented 2 years ago

In your 5G-NB-IoT_Arduino/5G-NB-IoT_MQTT.cpp you write

Mqtt_Client_Result_Status_t _5G_NB_IoT_MQTT::CreateMQTTClient(unsigned int mqtt_index, const char *client_id, const char *username, const char *password)
{
    char cmd[128], buf[128];
    strcpy(cmd, MQTT_CREATE_CLIENT);
    if (username != "" && password != ""){
        sprintf(buf, "=%d,\"%s\",\"%s\",\"%s\"", mqtt_index, client_id, username, password);
    } else {
        sprintf(buf, "=%d,\"%s\"", mqtt_index, client_id);
    }

how can that comparison work without strcmp?

lib\5G-NB-IoT_Arduino\5G-NB-IoT_MQTT.cpp:142:21: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (username != "" && password != ""){

Same with

    if(ca_cert_path == "" && client_cert_path == "" && client_key_path == ""){

in 5G-NB-IoT_SSL.cpp