Do not error when md_kt_size() is called with mdname="none"
PATCH 1/1 Do not error when md_kt_size() is called with mdname="none"
From: Selva Nair <[email protected]...>
An easy way to trigger this error is to run an otherwise working setup (at say verb = 4) with increased verbosity of verb >= 7 and using a GCM cipher (e.g., AES-256-GCM). It will cause a fatal exit while printing the cipher and hmac in key2_print().
---
Its actually md_get("none") called by md_kt_size("none") that causes the error and I'm not entirely sure whether we should instead make md_get("none") to return NULL. But that would require all its callers to check for NULL.
src/openvpn/crypto_openssl.c | 4 ++++ 1 file changed, 4 insertions(+)
src/openvpn/crypto_openssl.c +4 -0
@@ -1073,6 +1073,10 @@ md_kt_name(const char *mdname)unsigned char md_kt_size (const char *mdname) { +if (!strcmp ("none" , mdname)) + { +return 0 ; + }evp_md_type *kt =md_get (mdname);unsigned char size = (unsigned char )EVP_MD_size (kt);EVP_MD_free (kt);
Signature · 1 line
2.30.2
Am 21.01.22 um 19:57 schrieb [email protected]...:
Quoted 7 lines
From: Selva Nair <[email protected]...>
An easy way to trigger this error is to run an otherwise working setup (at say verb = 4) with increased verbosity of verb >= 7 and using a GCM cipher (e.g., AES-256-GCM). It will cause a fatal exit while printing the cipher and hmac in
key2_print().
Quoted 6 lines
Signed-off-by Selva Nair <[email protected]...>---
Its actuallymd_get("none")called bymd_kt_size("none")that causes the error and I'm not entirely sure whether we should instead makemd_get("none")to return NULL. But that would require all its callers to check for NULL.
Thanks for finding this.
Hi,
src/openvpn/crypto_openssl.c md_kt_name(const char *mdname) · line 1076
Quoted 9 lines · On 21/01/2022 19:57, [email protected]... wrote:
src/openvpn/crypto_openssl.c +1
-0@@ -1073,6 +1073,10 @@ md_kt_name(const char *mdname)unsigned char md_kt_size (const char *mdname) { +if (!strcmp ("none" , mdname))
Since we have it implemented, can we use streq() here?
Cheers,
Signature · 1 line
Antonio Quartulli
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi,
Quoted 16 lines · Arne Schwabe
Am 25.01.22 um 17:27 schrieb Antonio Quartulli:
Quoted 15 lines
Hi,
Quoted 9 lines · On 21/01/2022 19:57, [email protected]... wrote:
src/openvpn/crypto_openssl.c +0
-0@@ -1073,6 +1073,10 @@ md_kt_name(const char *mdname)unsigned char
md_kt_size(const char *mdname)
{
+ if (!strcmp("none", mdname))Since we have it implemented, can we use
streq()here?
Quoted 4 lines
Quoted 2 lines
Cheers,
streq is mainly used in
option.conly, almost all other codes uses strcmp insteads, so not really that strong of an argument.
I thought options.c was part of this project too :-D
To be honest, I think streq() is not really useful, but then we should either use it consistently or just drop it.
I am in favour of dropping it because including options.h in other .c files can be quite a nightmare and you don't want that just to use streq().
So I guess we can live with this patch, but should we put on the agenda wiping streq() for good?
Cheers,
Quoted 3 lines
Arne
Signature · 1 line
Antonio Quartulli
Hi,
Quoted 30 lines · Antonio Quartulli
Hi,
Quoted 5 lines · Arne Schwabe
Am 25.01.22 um 17:27 schrieb Antonio Quartulli:
Quoted 4 lines
Hi,
Review
Quoted 1 line · On 21/01/2022 19:57, [email protected]... wrote:
(quoted diff) +0
-0
b/src/openvpn/crypto_openssl.cQuoted 11 lines
Quoted 11 lines
src/openvpn/crypto_openssl.c md_kt_name(const char *mdname) · line 1076
Quoted 8 lines
index
35fb0052..b93c680a100644src/openvpn/crypto_openssl.c +1
-0@@ -1073,6 +1073,10 @@ md_kt_name(const char *mdname)unsigned char md_kt_size (const char *mdname) { +if (!strcmp ("none" , mdname))Since we have it implemented, can we use
streq()here?Quoted 5 lines
Quoted 2 lines
Cheers,
streq is mainly used in
option.conly, almost all other codes uses strcmp insteads, so not really that strong of an argument.I thought
options.cwas part of this project too :-D
To be honest, I thinkstreq()is not really useful, but then we should either use it consistently or just drop it.
Quoted 6 lines
I am in favour of dropping it because including
options.hin other .c files can be quite a nightmare and you don't want that just to usestreq().So I guess we can live with this patch, but should we put on the agenda wiping
streq()for good?
"live with" ? When did strcmp() become a pariah?
Though strcmp()'s naming and return value are arguably not intuitive, we are all used to it. That said, we have 472 uses of streq(), so let it be. Just do not require that one should be preferred over the other.
Consistency is a good goal, but let's not be pedantic about it.
Selva
Hi,
Quoted 43 lines · Selva Nair
Hi,
On Tue, Jan 25, 2022 at 11:35 AM Antonio Quartulli <[email protected]... <mailto:[email protected]...>> wrote:
Hi, On 25/01/2022 17:30, Arne Schwabe wrote: > Am 25.01.22 um 17:27 schrieb Antonio Quartulli: >> Hi, >> >> On 21/01/2022 19:57, [email protected]... <mailto:[email protected]...> wrote: >>> diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c >>> index 35fb0052..b93c680a 100644 >>> --- a/src/openvpn/crypto_openssl.c >>> +++ b/src/openvpn/crypto_openssl.c >>> @@ -1073,6 +1073,10 @@ md_kt_name(const char *mdname) >>> unsigned char >>> md_kt_size(const char *mdname) >>> { >>> + if (!strcmp("none", mdname)) >> >> Since we have it implemented, can we use streq() here? >> >> Cheers, >> > > streq is mainly used in option.c only, almost all other codes uses > strcmp insteads, so not really that strong of an argument. I thought options.c was part of this project too :-D To be honest, I think streq() is not really useful, but then we should either use it consistently or just drop it. I am in favour of dropping it because including options.h in other .c files can be quite a nightmare and you don't want that just to use streq(). So I guess we can live with this patch, but should we put on the agenda wiping streq() for good?
Quoted 1 line
"live with" ? When did
strcmp()become a pariah?
Sorry, I didn't mean to have an offensive behaviour. Maybe I chose the wrong language.
What I meant was: since we already have a mix of strcmp and streq in the code and since Arne sounded reluctant to suggest changing this patch, I basically wanted to agree with keeping this patch as is. (read "live with" as "accept" or "ack").
Quoted 3 lines
Though strcmp()'s naming and return value are arguably not intuitive, we are all used to it. That said, we have 472 uses of
streq(), so let it be. Just do not require that one should be preferred over the other.
I am all in favour of simply using strcmp. It's just that our code is a partial mix up and that is not nice (imho). This is why I suggested that we should put on the agenda wiping streq entirely and be done with it.
Quoted 1 line
Consistency is a good goal, but let's not be pedantic about it.
True, but, if not pursued, consistency easily become inconsistency and at some point we are forced to clean things up.
Now, the streq/strcmp dilemma is just a marginal thing compared to other inconsistencies we have and I did not want to make a big deal about it. Sorry if it sounded so.
Cheers,
Signature · 1 line
Antonio Quartulli
[Openvpn-devel] [PATCH applied] Re: Do not error when md_kt_size() is called with mdname=none
In reply to [email protected]...Patch + explanation make sense and Arne indeed ACKed this. Thanks.
Reproduced the problem (GCM + verb7):
2022-01-26 14:40:34 us=15705 Data Channel: using negotiated cipher 'AES-256-GCM' ... 2022-01-26 14:40:34 us=15829 Message hash algorithm 'none' not found 2022-01-26 14:40:34 us=15849 Exiting due to fatal error
and can see the fix work
2022-01-26 14:42:38 us=355685 Data Channel: using negotiated cipher 'AES-256-GCM' ... 2022-01-26 14:42:38 us=355782 Master Encrypt (cipher): 0ba0d2b3 83f3f160 3ff8fe87 11c22db7 dc67c1fd 7f9ba3f0 9077f9e9 7ee77cf2 2022-01-26 14:42:38 us=355791 Master Encrypt (hmac): ... 2022-01-26 14:42:38 us=355897 Incoming Data Channel: CIPHER block_size=16 iv_size=12 2022-01-26 14:42:38 us=356020 ROUTE_GATEWAY 193.149.48.190/255.255.255.192 IFACE=bge0 HWADDR=3c:a8:2a:9f:70:90
Your patch has been applied to the master branch.
commit 9076d90684c06c8f0ac0ba4c099b00ddbc4ab29d
Author: Selva Nair Date: Fri Jan 21 13:57:52 2022 -0500
Do not error when md_kt_size() is called with mdname=none
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23631.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering