diff options
author | George Hazan <ghazan@miranda.im> | 2020-02-07 17:42:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-02-07 17:42:52 +0300 |
commit | 0f594b2f7ca05b59f96d6c444d96cd04c9c084fe (patch) | |
tree | 811a5ee843a33610c81fe82dbaf724a212e14e13 /protocols/ICQ-WIM | |
parent | 17a3d4fb3af78adc70b0dc8d0b8eafdb245b396f (diff) |
fixes #2203 (ICQ-WIM: crash on image receive)
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 88388e9bd6..7c8100eca7 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -136,6 +136,9 @@ struct IcqFileTransfer : public MZeroedObject pfts.flags = PFTS_UNICODE | PFTS_RECEIVING; ptrW pwszFileName(mir_utf8decodeW(pszUrl)); + if (pwszFileName == nullptr) + pwszFileName = mir_a2u(pszUrl); + const wchar_t *p = wcsrchr(pwszFileName, '/'); m_wszFileName = (p == nullptr) ? pwszFileName : p + 1; m_wszShortName = m_wszFileName; diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 43b0112907..40dde5a451 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -787,6 +787,11 @@ void CIcqProto::OnFileInit(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pOld) ///////////////////////////////////////////////////////////////////////////////////////// +static bool sttIsXDigit(char c) +{ + return (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9'); +} + void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { RobustReply root(pReply); @@ -800,7 +805,7 @@ void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) mir_urlDecode(&*szUrl.begin()); for (size_t i = 0; i < szUrl.length(); ++i) - if (szUrl[i] == '_' && isxdigit(szUrl[i+1]) && isxdigit(szUrl[i+2])) { + if (szUrl[i] == '_' && sttIsXDigit(szUrl[i+1]) && sttIsXDigit(szUrl[i+2])) { int c; if (1 == sscanf(szUrl.c_str() + i + 1, "%02x", &c)) szUrl.replace(i, 3, 1, c); |