|
3 | 3 | * |
4 | 4 | * Created on: Oct 28.2018 |
5 | 5 | * |
6 | | - * Version 3.0.13zd |
| 6 | + * Version 3.0.13ze |
7 | 7 | * Updated on: Dec 30.2024 |
8 | 8 | * Author: Wolle (schreibfaul1) |
9 | 9 | * |
@@ -528,8 +528,8 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { |
528 | 528 | xSemaphoreTakeRecursive(mutex_playAudioData, 0.3 * configTICK_RATE_HZ); |
529 | 529 |
|
530 | 530 | // optional basic authorization |
531 | | - authLen = strlen(user) + strlen(pwd); |
532 | | - char authorization[base64_encode_expected_len(authLen + 1) + 1]; |
| 531 | + if(user && pwd) authLen = strlen(user) + strlen(pwd); |
| 532 | + char authorization[base64_encode_expected_len(authLen + 1) + 1]; |
533 | 533 | authorization[0] = '\0'; |
534 | 534 | if(authLen > 0) { |
535 | 535 | char toEncode[authLen + 4]; |
@@ -563,22 +563,6 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { |
563 | 563 | h_host[pos_colon] = '\0'; |
564 | 564 | } |
565 | 565 |
|
566 | | - // // optional basic authorization |
567 | | - // if(strlen(user) > 0 && strlen(pwd) > 0) { |
568 | | - // authLen = strlen(user) + strlen(pwd); |
569 | | - // authorization = x_ps_calloc(base64_encode_expected_len(authLen + 1), 1); |
570 | | - // if(!authorization) {AUDIO_INFO("out of memory"); stopSong(); goto exit;} |
571 | | - // toEncode = x_ps_calloc(authLen + 4, 1); |
572 | | - // if(!toEncode) {AUDIO_INFO("out of memory"); stopSong(); goto exit;} |
573 | | - // strcpy(toEncode, user); |
574 | | - // strcat(toEncode, ":"); |
575 | | - // strcat(toEncode, pwd); |
576 | | - // b64encode((const char*)toEncode, strlen(toEncode), authorization); |
577 | | - // } |
578 | | - // else{ |
579 | | - // authorization = strdup(""); |
580 | | - // } |
581 | | - |
582 | 566 | setDefaults(); |
583 | 567 | rqh = x_ps_calloc(lenHost + strlen(authorization) + 300, 1); // http request header |
584 | 568 | if(!rqh) {AUDIO_INFO("out of memory"); stopSong(); goto exit;} |
@@ -653,7 +637,6 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { |
653 | 637 | xSemaphoreGiveRecursive(mutex_playAudioData); |
654 | 638 | x_ps_free(h_host); |
655 | 639 | x_ps_free(rqh); |
656 | | - // x_ps_free(authorization); |
657 | 640 | x_ps_free(toEncode); |
658 | 641 | return res; |
659 | 642 | } |
@@ -3809,7 +3792,8 @@ bool Audio::parseHttpResponseHeader() { // this is the response to a GET / reque |
3809 | 3792 | if(!strncmp(c_host, m_lastHost, pos_slash)) { |
3810 | 3793 | AUDIO_INFO("redirect to new extension at existing host \"%s\"", c_host); |
3811 | 3794 | if(m_playlistFormat == FORMAT_M3U8) { |
3812 | | - strcpy(m_lastHost, c_host); |
| 3795 | + x_ps_free(m_lastHost); |
| 3796 | + m_lastHost = strdup(c_host); |
3813 | 3797 | m_f_m3u8data = true; |
3814 | 3798 | } |
3815 | 3799 | httpPrint(c_host); |
|
0 commit comments