Repository: trafficserver Updated Branches: refs/heads/master c9d443353 -> fa655be29
TS-2893: fix casting bug while tokenizing SSL certificate lists Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f1090b6f Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f1090b6f Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f1090b6f Branch: refs/heads/master Commit: f1090b6f05eaa88ea6bf9b7b3c42856b8766e4b0 Parents: c9d4433 Author: James Peach <jpe...@apache.org> Authored: Tue Jul 8 13:11:41 2014 -0700 Committer: James Peach <jpe...@apache.org> Committed: Tue Jul 8 13:12:44 2014 -0700 ---------------------------------------------------------------------- iocore/net/SSLUtils.cc | 4 ++-- lib/ts/SimpleTokenizer.h | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f1090b6f/iocore/net/SSLUtils.cc ---------------------------------------------------------------------- diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc index 3546219..4afd562 100644 --- a/iocore/net/SSLUtils.cc +++ b/iocore/net/SSLUtils.cc @@ -972,8 +972,8 @@ SSLInitServerContext( } if (!params->serverCertChainFilename && !sslMultCertSettings.ca && sslMultCertSettings.cert) { - SimpleTokenizer cert_tok(sslMultCertSettings.cert, SSL_CERT_SEPARATE_DELIM); - SimpleTokenizer key_tok((char *)(sslMultCertSettings.key ? (const char *)sslMultCertSettings.key : ats_strdup("")), SSL_CERT_SEPARATE_DELIM); + SimpleTokenizer cert_tok((const char *)sslMultCertSettings.cert, SSL_CERT_SEPARATE_DELIM); + SimpleTokenizer key_tok((sslMultCertSettings.key ? (const char *)sslMultCertSettings.key : ""), SSL_CERT_SEPARATE_DELIM); if (sslMultCertSettings.key && cert_tok.getNumTokensRemaining() != key_tok.getNumTokensRemaining()) { Error("the number of certificates in ssl_cert_name and ssl_key_name doesn't match"); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f1090b6f/lib/ts/SimpleTokenizer.h ---------------------------------------------------------------------- diff --git a/lib/ts/SimpleTokenizer.h b/lib/ts/SimpleTokenizer.h index 25e8f0f..929a606 100644 --- a/lib/ts/SimpleTokenizer.h +++ b/lib/ts/SimpleTokenizer.h @@ -125,11 +125,12 @@ public: OVERWRITE_INPUT_STRING = 8 }; - SimpleTokenizer(char delimiter = ' ', int mode = 0, char escape = '\\') + SimpleTokenizer(char delimiter = ' ', unsigned mode = 0, char escape = '\\') : _data(0), _delimiter(delimiter), _mode(mode), _escape(escape), _start(0), _length(0) { } -SimpleTokenizer(char *s, char delimiter = ' ', int mode = 0, char escape = '\\') + // NOTE: The input strring 's' is overwritten for mode OVERWRITE_INPUT_STRING. + SimpleTokenizer(const char *s, char delimiter = ' ', unsigned mode = 0, char escape = '\\') : _data(0), _delimiter(delimiter), _mode(mode), _escape(escape) { setString(s); @@ -139,13 +140,13 @@ SimpleTokenizer(char *s, char delimiter = ' ', int mode = 0, char escape = '\\') _clearData(); } - void setString(char *s) + void setString(const char *s) { _clearData(); _start = 0; _length = strlen(s); - _data = (_mode & OVERWRITE_INPUT_STRING ? s : ats_strdup(s)); + _data = (_mode & OVERWRITE_INPUT_STRING ? const_cast<char *>(s) : ats_strdup(s)); // to handle the case where there is a null field at the end of the // input string, we replace the null character at the end of the @@ -186,7 +187,7 @@ private: char *_data; // a pointer to the input data itself, // or to a copy of it char _delimiter; // the token delimiter - int _mode; // flags that determine the + unsigned _mode; // flags that determine the // mode of operation char _escape; // the escape character size_t _start; // pointer to the start of the next