| From 9f97479373f3fceedc471074b81486d77a49618d Mon Sep 17 00:00:00 2001 |
| From: "Roy.Li" <rongqing.li@windriver.com> |
| Date: Tue, 4 Mar 2014 14:38:42 +0800 |
| Subject: [PATCH] fix the function parameter |
| |
| Upstream-Status: Pending |
| |
| Original openssl_diffie_hellman_create has three parameters, but |
| it is reassigned a function pointer which has one parameter, and |
| is called with one parameter, which will lead to segment fault |
| on PPC, Now we simply correct the number of parameters. |
| |
| #0 0x484d4aa0 in __GI_raise (sig=6) |
| at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 |
| #1 0x484d9930 in __GI_abort () at abort.c:91 |
| #2 0x10002064 in segv_handler (signal=11) at charon.c:224 |
| #3 <signal handler called> |
| #4 0x48d89630 in openssl_diffie_hellman_create (group=MODP_1024_BIT, g=..., |
| p=<error reading variable: Cannot access memory at address 0x0>) |
| at openssl_diffie_hellman.c:143 |
| #5 0x482c54f8 in create_dh (this=0x11ac6e68, group=MODP_1024_BIT) |
| at crypto/crypto_factory.c:358 |
| #6 0x48375884 in create_dh (this=<optimized out>, group=<optimized out>) |
| at sa/keymat.c:132 |
| #7 0x483843b8 in process_payloads (this=0x51400a78, message=<optimized |
| out>) |
| at sa/tasks/ike_init.c:200 |
| #8 0x483844d0 in process_r (this=0x51400a78, message=0x51500778) |
| at sa/tasks/ike_init.c:319 |
| #9 0x48374c9c in process_request (message=0x51500778, this=0x51400d20) |
| at sa/task_manager.c:870 |
| #10 process_message (this=0x51400d20, msg=0x51500778) at |
| sa/task_manager.c:925 |
| #11 0x4836c378 in process_message (this=0x514005f0, message=0x51500778) |
| at sa/ike_sa.c:1317 |
| #12 0x48362270 in execute (this=0x515008d0) |
| at processing/jobs/process_message_job.c:74 |
| |
| Signed-off-by: Roy.Li <rongqing.li@windriver.com> |
| |
| --- |
| src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c | 8 +++++++- |
| src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h | 4 +++- |
| src/libstrongswan/plugins/openssl/openssl_plugin.c | 1 + |
| 3 files changed, 11 insertions(+), 2 deletions(-) |
| |
| diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
| index 8e9c118..a73b038 100644 |
| --- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
| +++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
| @@ -192,7 +192,7 @@ METHOD(diffie_hellman_t, destroy, void, |
| /* |
| * Described in header. |
| */ |
| -openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| +openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom( |
| diffie_hellman_group_t group, ...) |
| { |
| private_openssl_diffie_hellman_t *this; |
| @@ -255,5 +255,11 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| DBG2(DBG_LIB, "size of DH secret exponent: %d bits", BN_num_bits(privkey)); |
| return &this->public; |
| } |
| +openssl_diffie_hellman_t *openssl_diffie_hellman_create( diffie_hellman_group_t group) |
| +{ |
| + chunk_t g; |
| + chunk_t p; |
| + openssl_diffie_hellman_create_custom(group, g, p); |
| +} |
| |
| #endif /* OPENSSL_NO_DH */ |
| diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
| index 5de5520..22586e0 100644 |
| --- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
| +++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
| @@ -43,8 +43,10 @@ struct openssl_diffie_hellman_t { |
| * @param ... expects generator and prime as chunk_t if MODP_CUSTOM |
| * @return openssl_diffie_hellman_t object, NULL if not supported |
| */ |
| -openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| +openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom( |
| diffie_hellman_group_t group, ...); |
| +openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| + diffie_hellman_group_t group); |
| |
| #endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/ |
| |
| diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c |
| index 8b0a7c5..114d575 100644 |
| --- a/src/libstrongswan/plugins/openssl/openssl_plugin.c |
| +++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c |
| @@ -609,6 +609,7 @@ METHOD(plugin_t, get_features, int, |
| PLUGIN_PROVIDE(DH, MODP_1024_BIT), |
| PLUGIN_PROVIDE(DH, MODP_1024_160), |
| PLUGIN_PROVIDE(DH, MODP_768_BIT), |
| + PLUGIN_REGISTER(DH, openssl_diffie_hellman_create_custom), |
| PLUGIN_PROVIDE(DH, MODP_CUSTOM), |
| #endif |
| #ifndef OPENSSL_NO_RSA |