diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 2d49ccf93ca..2c0ef612ead 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 5.0 Changelog +* v5.0, 2022-11-21, Asan: Fix global ip address leak check. v5.0.90 * v5.0, 2022-11-20, For [#2532](https://github.com/ossrs/srs/issues/2532): Windows: Support cygwin pipline and packager. v5.0.89 * v5.0, 2022-11-18, Fix [#3215](https://github.com/ossrs/srs/issues/3215): Callback: Fix bug for response string 0. v5.0.88 * v5.0, 2022-11-18, For [#2532](https://github.com/ossrs/srs/issues/2532): Windows: Replace ln by cp for windows. v5.0.87 diff --git a/trunk/src/app/srs_app_tencentcloud.cpp b/trunk/src/app/srs_app_tencentcloud.cpp index 82ae790c84d..2b4ac9c9a84 100644 --- a/trunk/src/app/srs_app_tencentcloud.cpp +++ b/trunk/src/app/srs_app_tencentcloud.cpp @@ -135,7 +135,7 @@ namespace tencentcloud_api_sign { http_request_info[http_request_info.size() - 1] = '\n'; } //printf("%s\nEOF\n", http_request_info.c_str()); - char signed_time[SIGNLEN]; + char signed_time[SIGNLEN] = {0}; int signed_time_len = snprintf(signed_time, SIGNLEN, "%lu;%lu", time(0) - 60, time(0) + expire); //snprintf(signed_time, SIGNLEN, "1510109254;1510109314"); @@ -147,16 +147,14 @@ namespace tencentcloud_api_sign { .append(sha1(http_request_info.c_str(), http_request_info.size())) .append("\n"); //printf("%s\nEOF\n", str_to_sign.c_str()); - char c_signature[SIGNLEN]; - snprintf(c_signature, SIGNLEN, - "q-sign-algorithm=sha1&q-ak=%s" - "&q-sign-time=%s&q-key-time=%s" - "&q-header-list=%s&q-url-param-list=%s&q-signature=%s", - secret_id.c_str(), signed_time, signed_time, - header_list.c_str(), uri_parm_list.c_str(), - hmac_sha1(signkey.c_str(), str_to_sign.c_str(), - str_to_sign.size()).c_str()); - return c_signature; + std::stringstream c_signature; + c_signature << "q-sign-algorithm=sha1&q-ak=" << secret_id.c_str() + << "&q-sign-time=" << signed_time + << "&q-key-time=" << signed_time + << "&q-header-list=" << header_list.c_str() + << "&q-url-param-list=" << uri_parm_list.c_str() + << "&q-signature=" << hmac_sha1(signkey.c_str(), str_to_sign.c_str(), str_to_sign.size()).c_str(); + return c_signature.str(); } } diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 6aef6f4579c..b068033ca84 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -73,6 +73,9 @@ bool _srs_config_by_env = false; // The binary name of SRS. const char* _srs_binary = NULL; +// Free global data, for address sanitizer. +extern void srs_free_global_system_ips(); + /** * main entrance. */ @@ -221,7 +224,9 @@ srs_error_t do_main(int argc, char** argv, char** envp) if ((err = run_directly_or_daemon()) != srs_success) { return srs_error_wrap(err, "run"); } - + + srs_free_global_system_ips(); + return err; } @@ -446,6 +451,7 @@ srs_error_t run_directly_or_daemon() int status = 0; waitpid(pid, &status, 0); srs_trace("grandpa process exit."); + srs_free_global_system_ips(); exit(0); } @@ -458,6 +464,7 @@ srs_error_t run_directly_or_daemon() if(pid > 0) { srs_trace("father process exit"); + srs_free_global_system_ips(); exit(0); }