Ticket #957:
- Updated Symbian PJLIB test build setting to enable SSL sock test.
- Fixed ciphers enumeration in Symbian SSL sock.
- Fixed OpenSSL SSL sock to avoid initializing OpenSSL multiple times.
- Fixed SSL unit test to avoid divide-by-zero in setting random seed.
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2990 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/build.symbian/pjlib_test.mmp b/build.symbian/pjlib_test.mmp
index 406b0d5..462b118 100644
--- a/build.symbian/pjlib_test.mmp
+++ b/build.symbian/pjlib_test.mmp
@@ -46,6 +46,7 @@
SOURCE sleep.c
SOURCE sock.c
SOURCE sock_perf.c
+SOURCE ssl_sock.c
SOURCE string.c
SOURCE test_wrap.cpp
SOURCE thread.c
@@ -68,7 +69,7 @@
SYSTEMINCLUDE \epoc32\include
SYSTEMINCLUDE \epoc32\include\libc
-LIBRARY esock.lib insock.lib charconv.lib euser.lib estlib.lib
+LIBRARY esock.lib insock.lib charconv.lib euser.lib estlib.lib securesocket.lib
#ifdef WINSCW
STATICLIBRARY eexe.lib ecrt0.lib
#endif
@@ -76,3 +77,4 @@
// Need a bit of mem for logging in the app.
EPOCSTACKSIZE 32768
+CAPABILITY NetworkServices LocalServices ReadUserData WriteUserData UserEnvironment
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index 76c321a..9c016a3 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -248,7 +248,7 @@
errstr.ptr = buf;
errstr.slen = pj_ansi_snprintf(buf, bufsize,
- "Unknown OpenSSL error %d",
+ "Unknown OpenSSL error %ul",
ssl_err);
return errstr;
@@ -267,9 +267,11 @@
/* Initialize OpenSSL */
static pj_status_t init_openssl(void)
{
- if (++openssl_init_count != 1)
+ if (openssl_init_count)
return PJ_SUCCESS;
+ openssl_init_count = 1;
+
/* Register error subsystem */
if (!openssl_reg_strerr) {
pj_status_t status;
@@ -334,8 +336,7 @@
/* Shutdown OpenSSL */
static void shutdown_openssl(void)
{
- if (--openssl_init_count != 0)
- return;
+ PJ_UNUSED_ARG(openssl_init_count);
}
diff --git a/pjlib/src/pj/ssl_sock_symbian.cpp b/pjlib/src/pj/ssl_sock_symbian.cpp
index 0619fd9..18dfd7c 100644
--- a/pjlib/src/pj/ssl_sock_symbian.cpp
+++ b/pjlib/src/pj/ssl_sock_symbian.cpp
@@ -447,7 +447,8 @@
if (ciphers_num_ > PJ_ARRAY_SIZE(ciphers_))
ciphers_num_ = PJ_ARRAY_SIZE(ciphers_);
for (i = 0; i < ciphers_num_; ++i)
- ciphers_[i] = (pj_ssl_cipher)ciphers_buf[i*2];
+ ciphers_[i] = (pj_ssl_cipher)(ciphers_buf[i*2]*10 +
+ ciphers_buf[i*2+1]);
}
delete secure_sock;
diff --git a/pjlib/src/pjlib-test/ssl_sock.c b/pjlib/src/pjlib-test/ssl_sock.c
index a1f9dca..e3563b6 100644
--- a/pjlib/src/pjlib-test/ssl_sock.c
+++ b/pjlib/src/pjlib-test/ssl_sock.c
@@ -610,7 +610,7 @@
pj_time_val now;
pj_gettimeofday(&now);
- pj_srand((pj_rand()%now.sec) * (pj_rand()%now.msec));
+ pj_srand((unsigned)now.sec);
state_cli.send_str_len = (pj_rand() % 5 + 1) * 1024 + pj_rand() % 1024;
}
state_cli.send_str = pj_pool_alloc(pool, state_cli.send_str_len);
@@ -1006,7 +1006,7 @@
pj_time_val now;
pj_gettimeofday(&now);
- pj_srand((pj_rand()%now.sec) * (pj_rand()%now.msec));
+ pj_srand((unsigned)now.sec);
}
/* Allocate SSL socket pointers and test state */