From 4792d21a68ac3e1290a499a3d023ba32fcc9d99b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Feb 2017 10:56:38 -0500 Subject: [PATCH 1/4] use source format 1.0 --- distros/ubuntu1604/source/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/ubuntu1604/source/format b/distros/ubuntu1604/source/format index 89ae9db8f..d3827e75a 100644 --- a/distros/ubuntu1604/source/format +++ b/distros/ubuntu1604/source/format @@ -1 +1 @@ -3.0 (native) +1.0 From 3b15ba91d104bbf5b884549420d9571e927ff570 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 20 Mar 2017 11:16:21 -0400 Subject: [PATCH 2/4] Rough in a CURL based UriDecode --- src/zm_utils.cpp | 19 +++++++++++++++++++ src/zm_utils.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 67af64a66..5e4919be4 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -25,6 +25,10 @@ #include #include +#ifdef HAVE_CURL_CURL_H +#include +#endif + unsigned int sseversion = 0; std::string trimSet(std::string str, std::string trimset) { @@ -345,3 +349,18 @@ void timespec_diff(struct timespec *start, struct timespec *end, struct timespec } } +std::string UriDecode( const std::string &encoded ) { +#ifdef HAVE_LIBCURL + CURL *curl = curl_easy_init(); + int outlength; + char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &outlength); + std::string res(cres, cres + outlength); + curl_free(cres); + curl_easy_cleanup(curl); + return res; +#else +Warning("ZM Compiled without LIBCURL. UriDecoding not implemented."); + return encoded; +#endif +} + diff --git a/src/zm_utils.h b/src/zm_utils.h index a6cb2e150..dec8061ea 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -60,4 +60,6 @@ void timespec_diff(struct timespec *start, struct timespec *end, struct timespec extern unsigned int sseversion; +std::string UriDecode( const std::string &encoded ); + #endif // ZM_UTILS_H From 9f30ccfa75e5db38055af31513abef2610793281 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 20 Mar 2017 11:16:39 -0400 Subject: [PATCH 3/4] Use new UriDecode function to decode username and password --- src/zms.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/zms.cpp b/src/zms.cpp index e40fcdf95..1945e188a 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -69,8 +69,8 @@ int main( int argc, const char *argv[] ) unsigned int bitrate = 100000; unsigned int ttl = 0; EventStream::StreamMode replay = EventStream::MODE_SINGLE; - char username[64] = ""; - char password[64] = ""; + std::string username; + std::string password; char auth[64] = ""; unsigned int connkey = 0; unsigned int playback_buffer = 0; @@ -164,7 +164,7 @@ int main( int argc, const char *argv[] ) { if ( !strcmp( name, "user" ) ) { - strncpy( username, value, sizeof(username) ); + username = value; } } else @@ -180,11 +180,11 @@ int main( int argc, const char *argv[] ) { if ( !strcmp( name, "user" ) ) { - strncpy( username, value, sizeof(username) ); + username = UriDecode(value); } if ( !strcmp( name, "pass" ) ) { - strncpy( password, value, sizeof(password) ); + password = UriDecode( password ); } } } @@ -198,9 +198,9 @@ int main( int argc, const char *argv[] ) if ( strcmp( config.auth_relay, "none" ) == 0 ) { - if ( *username ) + if ( username.length() ) { - user = zmLoadUser( username ); + user = zmLoadUser( username.c_str() ); } } else @@ -214,9 +214,9 @@ int main( int argc, const char *argv[] ) } //else if ( strcmp( config.auth_relay, "plain" ) == 0 ) { - if ( *username && *password ) + if ( username.length() && password.length() ) { - user = zmLoadUser( username, password ); + user = zmLoadUser( username.c_str(), password.c_str() ); } } } From b1d5fbef0bcf98f6a38447b194a7cb83f94916e6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 20 Mar 2017 13:19:50 -0400 Subject: [PATCH 4/4] revert an unintended change --- distros/ubuntu1604/source/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/ubuntu1604/source/format b/distros/ubuntu1604/source/format index d3827e75a..89ae9db8f 100644 --- a/distros/ubuntu1604/source/format +++ b/distros/ubuntu1604/source/format @@ -1 +1 @@ -1.0 +3.0 (native)