From 38620345658c63e840fa77ceea3edbad7549e80f Mon Sep 17 00:00:00 2001 From: eru Date: Thu, 8 May 2008 10:01:49 +0000 Subject: [PATCH] IM0027-4 --- PeerCast.root/PeerCast/core/common/channel.cpp | 2 +- PeerCast.root/PeerCast/core/common/http.cpp | 12 ++++++++--- PeerCast.root/PeerCast/core/common/http.h | 2 +- PeerCast.root/PeerCast/core/common/servent.h | 2 +- PeerCast.root/PeerCast/core/common/servhs.cpp | 8 ++++---- PeerCast.root/PeerCast/core/common/url.cpp | 2 +- PeerCast.root/PeerCast/core/common/version2.h | 4 ++-- .../PeerCast/core/win32/lib/corelib.vcproj | 7 +++++-- PeerCast.root/PeerCast/ui/win32/PeerCast.sln | 14 ++++++------- .../PeerCast/ui/win32/simple/Simple.vcproj | 24 ++++++++++------------ .../PeerCast.root/PeerCast/core/common/channel.cpp | 2 +- c:/Git/PeerCast.root/PeerCast/core/common/http.cpp | 12 ++++++++--- c:/Git/PeerCast.root/PeerCast/core/common/http.h | 2 +- .../PeerCast.root/PeerCast/core/common/servent.h | 2 +- .../PeerCast.root/PeerCast/core/common/servhs.cpp | 8 ++++---- c:/Git/PeerCast.root/PeerCast/core/common/url.cpp | 2 +- .../PeerCast.root/PeerCast/core/common/version2.h | 4 ++-- .../PeerCast/core/win32/lib/corelib.vcproj | 7 +++++-- .../PeerCast.root/PeerCast/ui/win32/PeerCast.sln | 14 ++++++------- .../PeerCast/ui/win32/simple/Simple.vcproj | 24 ++++++++++------------ 20 files changed, 84 insertions(+), 70 deletions(-) diff --git a/PeerCast.root/PeerCast/core/common/channel.cpp b/PeerCast.root/PeerCast/core/common/channel.cpp index c1b3e2b..b1262a2 100644 --- a/PeerCast.root/PeerCast/core/common/channel.cpp +++ b/PeerCast.root/PeerCast/core/common/channel.cpp @@ -570,7 +570,7 @@ int Channel::handshakeFetch() if (http.isHeader(PCX_HS_POS)) streamPos = atoi(arg); else - Servent::readICYHeader(http, info, NULL); + Servent::readICYHeader(http, info, NULL, 0); LOG_CHANNEL("Channel fetch: %s",http.cmdLine); } diff --git a/PeerCast.root/PeerCast/core/common/http.cpp b/PeerCast.root/PeerCast/core/common/http.cpp index 95f4df4..21d900e 100644 --- a/PeerCast.root/PeerCast/core/common/http.cpp +++ b/PeerCast.root/PeerCast/core/common/http.cpp @@ -107,7 +107,7 @@ int HTTP::getArgInt() return 0; } //----------------------------------------- -void HTTP::getAuthUserPass(char *user, char *pass) +void HTTP::getAuthUserPass(char *user, char *pass, size_t szUser, size_t szPass) { if (arg) { @@ -125,9 +125,15 @@ void HTTP::getAuthUserPass(char *user, char *pass) { *s = 0; if (user) - strcpy(user,str.cstr()); + { + strncpy(user, str.cstr(), szUser); + user[szUser-1] = '\0'; + } if (pass) - strcpy(pass,s+1); + { + strncpy(pass, s+1, szPass); + pass[szPass-1] = '\0'; + } } } } diff --git a/PeerCast.root/PeerCast/core/common/http.h b/PeerCast.root/PeerCast/core/common/http.h index 2627d3d..8f60404 100644 --- a/PeerCast.root/PeerCast/core/common/http.h +++ b/PeerCast.root/PeerCast/core/common/http.h @@ -176,7 +176,7 @@ public: char *getArgStr(); int getArgInt(); - void getAuthUserPass(char *, char *); + void getAuthUserPass(char *, char *, size_t, size_t); char cmdLine[8192],*arg; diff --git a/PeerCast.root/PeerCast/core/common/servent.h b/PeerCast.root/PeerCast/core/common/servent.h index 09aaac5..d590a90 100644 --- a/PeerCast.root/PeerCast/core/common/servent.h +++ b/PeerCast.root/PeerCast/core/common/servent.h @@ -213,7 +213,7 @@ public: void sendPCPChannel(); void checkPCPComms(Channel *, AtomStream &); - static void readICYHeader(HTTP &, ChanInfo &, char *); + static void readICYHeader(HTTP &, ChanInfo &, char *, size_t); bool canStream(Channel *); bool isConnected() {return status == S_CONNECTED;} diff --git a/PeerCast.root/PeerCast/core/common/servhs.cpp b/PeerCast.root/PeerCast/core/common/servhs.cpp index ac30b47..7217767 100644 --- a/PeerCast.root/PeerCast/core/common/servhs.cpp +++ b/PeerCast.root/PeerCast/core/common/servhs.cpp @@ -726,7 +726,7 @@ bool Servent::handshakeAuth(HTTP &http,const char *args,bool local) { case ServMgr::AUTH_HTTPBASIC: if (http.isHeader("Authorization")) - http.getAuthUserPass(user,pass); + http.getAuthUserPass(user, pass, sizeof(user), sizeof(pass)); break; case ServMgr::AUTH_COOKIE: if (http.isHeader("Cookie")) @@ -1708,7 +1708,7 @@ void Servent::handshakeXML() } // ----------------------------------- -void Servent::readICYHeader(HTTP &http, ChanInfo &info, char *pwd) +void Servent::readICYHeader(HTTP &http, ChanInfo &info, char *pwd, size_t szPwd) { char *arg = http.getArgStr(); if (!arg) return; @@ -1733,7 +1733,7 @@ void Servent::readICYHeader(HTTP &http, ChanInfo &info, char *pwd) info.desc.convertTo(String::T_UNICODE); }else if (http.isHeader("Authorization")) - http.getAuthUserPass(NULL,pwd); + http.getAuthUserPass(NULL, pwd, 0, sizeof(pwd)); else if (http.isHeader(PCX_HS_CHANNELID)) info.id.fromStr(arg); else if (http.isHeader("ice-password")) @@ -1804,7 +1804,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) while (http.nextHeader()) { LOG_DEBUG("ICY %s",http.cmdLine); - readICYHeader(http,info,loginPassword.cstr()); + readICYHeader(http, info, loginPassword.cstr(), loginPassword.MAX_LEN); } diff --git a/PeerCast.root/PeerCast/core/common/url.cpp b/PeerCast.root/PeerCast/core/common/url.cpp index f98d195..eccca20 100644 --- a/PeerCast.root/PeerCast/core/common/url.cpp +++ b/PeerCast.root/PeerCast/core/common/url.cpp @@ -180,7 +180,7 @@ int URLSource::getSourceRate() LOG_CHANNEL("Fetch HTTP: %s",http.cmdLine); ChanInfo tmpInfo = ch->info; - Servent::readICYHeader(http,ch->info,NULL); + Servent::readICYHeader(http, ch->info, NULL, 0); if (!tmpInfo.name.isEmpty()) ch->info.name = tmpInfo.name; diff --git a/PeerCast.root/PeerCast/core/common/version2.h b/PeerCast.root/PeerCast/core/common/version2.h index 2ae3f0f..f9517a0 100644 --- a/PeerCast.root/PeerCast/core/common/version2.h +++ b/PeerCast.root/PeerCast/core/common/version2.h @@ -45,8 +45,8 @@ extern int version_ex; // PP //#define VERSION_EX 1 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-3)"; -static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-3)"; +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)"; +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)"; #endif // ------------------------------------------------ diff --git a/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj b/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj index 6f7743e..a8ddb0d 100644 --- a/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj +++ b/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj @@ -1,13 +1,14 @@ - - - - info; - Servent::readICYHeader(http,ch->info,NULL); + Servent::readICYHeader(http, ch->info, NULL, 0); if (!tmpInfo.name.isEmpty()) ch->info.name = tmpInfo.name; diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h index 2ae3f0f..f9517a0 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h +++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h @@ -45,8 +45,8 @@ extern int version_ex; // PP //#define VERSION_EX 1 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-3)"; -static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-3)"; +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)"; +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)"; #endif // ------------------------------------------------ diff --git a/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj b/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj index 6f7743e..a8ddb0d 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj +++ b/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj @@ -1,13 +1,14 @@ - - - -