Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From 9f97479373f3fceedc471074b81486d77a49618d Mon Sep 17 00:00:00 2001 |
| 2 | From: "Roy.Li" <rongqing.li@windriver.com> |
| 3 | Date: Tue, 4 Mar 2014 14:38:42 +0800 |
| 4 | Subject: [PATCH] fix the function parameter |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 5 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 6 | Upstream-Status: Pending |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 7 | |
| 8 | Original openssl_diffie_hellman_create has three parameters, but |
| 9 | it is reassigned a function pointer which has one parameter, and |
| 10 | is called with one parameter, which will lead to segment fault |
| 11 | on PPC, Now we simply correct the number of parameters. |
| 12 | |
| 13 | #0 0x484d4aa0 in __GI_raise (sig=6) |
| 14 | at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 |
| 15 | #1 0x484d9930 in __GI_abort () at abort.c:91 |
| 16 | #2 0x10002064 in segv_handler (signal=11) at charon.c:224 |
| 17 | #3 <signal handler called> |
| 18 | #4 0x48d89630 in openssl_diffie_hellman_create (group=MODP_1024_BIT, g=..., |
| 19 | p=<error reading variable: Cannot access memory at address 0x0>) |
| 20 | at openssl_diffie_hellman.c:143 |
| 21 | #5 0x482c54f8 in create_dh (this=0x11ac6e68, group=MODP_1024_BIT) |
| 22 | at crypto/crypto_factory.c:358 |
| 23 | #6 0x48375884 in create_dh (this=<optimized out>, group=<optimized out>) |
| 24 | at sa/keymat.c:132 |
| 25 | #7 0x483843b8 in process_payloads (this=0x51400a78, message=<optimized |
| 26 | out>) |
| 27 | at sa/tasks/ike_init.c:200 |
| 28 | #8 0x483844d0 in process_r (this=0x51400a78, message=0x51500778) |
| 29 | at sa/tasks/ike_init.c:319 |
| 30 | #9 0x48374c9c in process_request (message=0x51500778, this=0x51400d20) |
| 31 | at sa/task_manager.c:870 |
| 32 | #10 process_message (this=0x51400d20, msg=0x51500778) at |
| 33 | sa/task_manager.c:925 |
| 34 | #11 0x4836c378 in process_message (this=0x514005f0, message=0x51500778) |
| 35 | at sa/ike_sa.c:1317 |
| 36 | #12 0x48362270 in execute (this=0x515008d0) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | at processing/jobs/process_message_job.c:74 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 38 | |
| 39 | Signed-off-by: Roy.Li <rongqing.li@windriver.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 41 | --- |
| 42 | src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c | 8 +++++++- |
| 43 | src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h | 4 +++- |
| 44 | src/libstrongswan/plugins/openssl/openssl_plugin.c | 1 + |
| 45 | 3 files changed, 11 insertions(+), 2 deletions(-) |
| 46 | |
| 47 | diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 48 | index 8e9c118..a73b038 100644 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 49 | --- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
| 50 | +++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | @@ -192,7 +192,7 @@ METHOD(diffie_hellman_t, destroy, void, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 52 | /* |
| 53 | * Described in header. |
| 54 | */ |
| 55 | -openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| 56 | +openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom( |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 57 | diffie_hellman_group_t group, ...) |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 58 | { |
| 59 | private_openssl_diffie_hellman_t *this; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | @@ -255,5 +255,11 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| 61 | DBG2(DBG_LIB, "size of DH secret exponent: %d bits", BN_num_bits(privkey)); |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 62 | return &this->public; |
| 63 | } |
| 64 | +openssl_diffie_hellman_t *openssl_diffie_hellman_create( diffie_hellman_group_t group) |
| 65 | +{ |
| 66 | + chunk_t g; |
| 67 | + chunk_t p; |
| 68 | + openssl_diffie_hellman_create_custom(group, g, p); |
| 69 | +} |
| 70 | |
| 71 | #endif /* OPENSSL_NO_DH */ |
| 72 | diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 73 | index 5de5520..22586e0 100644 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 74 | --- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
| 75 | +++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 76 | @@ -43,8 +43,10 @@ struct openssl_diffie_hellman_t { |
| 77 | * @param ... expects generator and prime as chunk_t if MODP_CUSTOM |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 78 | * @return openssl_diffie_hellman_t object, NULL if not supported |
| 79 | */ |
| 80 | -openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| 81 | +openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom( |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 82 | diffie_hellman_group_t group, ...); |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 83 | +openssl_diffie_hellman_t *openssl_diffie_hellman_create( |
| 84 | + diffie_hellman_group_t group); |
| 85 | |
| 86 | #endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/ |
| 87 | |
| 88 | diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 89 | index 8b0a7c5..114d575 100644 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 90 | --- a/src/libstrongswan/plugins/openssl/openssl_plugin.c |
| 91 | +++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 92 | @@ -609,6 +609,7 @@ METHOD(plugin_t, get_features, int, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 93 | PLUGIN_PROVIDE(DH, MODP_1024_BIT), |
| 94 | PLUGIN_PROVIDE(DH, MODP_1024_160), |
| 95 | PLUGIN_PROVIDE(DH, MODP_768_BIT), |
| 96 | + PLUGIN_REGISTER(DH, openssl_diffie_hellman_create_custom), |
| 97 | PLUGIN_PROVIDE(DH, MODP_CUSTOM), |
| 98 | #endif |
| 99 | #ifndef OPENSSL_NO_RSA |