crypto.c: fix Visual Studio build
PATCH 1/1 crypto.c: fix Visual Studio build
From: Lev Stipakov <[email protected]...>
Commit fb4e8ab added variable-length array which is C99 feature and is not supported by Visual Studio.
This removes VLA and writes data directly into passed buffer.
--- src/openvpn/crypto.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
src/openvpn/crypto.c +7 -3
@@ -1895,14 +1895,18 @@ cleanup:bool generate_ephemeral_key (struct buffer *key,const char *key_name) { +const int len =BCAP (key); +msg (M_INFO ,"Using random %s." , key_name); -uint8_t rand[BCAP (key)]; -if (!rand_bytes (rand,BCAP (key))) + +if (!rand_bytes (BEND (key), len)) {msg (M_WARN ,"ERROR: could not generate random key" );return false; } -buf_write (key, rand,BCAP (key)); + +buf_inc_len (key, len); +return true; }
Signature · 1 line
2.7.4
Hi,
Quoted 17 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
Commit fb4e8ab added variable-length array which is C99 feature and is not supported by Visual Studio.
This removes VLA and writes data directly into passed buffer.
Signed-off-by Lev Stipakov <[email protected]...>--- src/openvpn/crypto.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)src/openvpn/crypto.c +0
-0
src/openvpn/crypto.c cleanup: · line 1902
Quoted 10 lines
src/openvpn/crypto.c +4
-2@@ -1895,14 +1895,18 @@ cleanup:bool generate_ephemeral_key (struct buffer *key,const char *key_name) { +const int len =BCAP (key); +msg (M_INFO ,"Using random %s." , key_name); -uint8_t rand[BCAP (key)]; -if (!rand_bytes (rand,BCAP (key))) + +if (!rand_bytes (BEND (key), len))
Are we sure we can't call this function with 'len' longer than the available space in 'key' ?
Cheers,
Quoted 12 lines
src/openvpn/crypto.c +3
-1{msg (M_WARN ,"ERROR: could not generate random key" );return false; } -buf_write (key, rand,BCAP (key)); + +buf_inc_len (key, len); +return true; }
Signature · 1 line
Antonio Quartulli
Hi,
Quoted 2 lines
Are we sure we can't call this function with 'len' longer than the available space in 'key' ?
Yep, because we get available space here:
Quoted 2 lines
+ const int len = BCAP(key);
and then pass it to rand_bytes:
Quoted 1 line
Quoted 1 line
+ if (!rand_bytes(BEND(key), len))
Signature · 1 line
-Lev
Quoted 7 lines · Lev Stipakov
Hi,
Quoted 2 lines
Are we sure we can't call this function with 'len' longer than the available space in 'key' ?
Quoted 7 lines
Yep, because we get available space here:
Quoted 2 lines
+ const int len = BCAP(key);
and then pass it to
rand_bytes:
Ok, that sounds good, thanks!
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
+ if (!rand_bytes(BEND(key), len))
Signature · 1 line
Antonio Quartulli
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
PATCH 1/1 crypto.c: fix Visual Studio build
Moving discussion to -devel.
By the way, are you aware that we already perform Visual Studio builds in appveyor?
https://ci.appveyor.com/project/mattock/openvpn-build/history
Do you think we should have both?
What would be nice to have is to trigger VS build on every commit to openvpn repo, since openvpn-build is something we run manually.
---------- Forwarded message ---------
Lähettäjä: Илья Шипицин <[email protected]...>
Date: su 21. heinäk. 2019 klo 18.17
Subject: Re: [Openvpn-devel] [PATCH] crypto.c: fix Visual Studio build
To: Lev Stipakov <[email protected]...>
чт, 18 июл. 2019 г. в 16:26, Lev Stipakov <[email protected]...>:
Quoted 5 lines
Hi,
to 18. heinäk. 2019 klo 14.15 Илья Шипицин ([email protected]...) kirjoitti:
Quoted 9 lines
Quoted 2 lines
btw, can you share steps required for Visual Studio builds ?
Just clone
https://github.com/openvpn/openvpn-build
and run
I used to think we can run build from 'openvpn/openvpn' repo. well, openvpn-build is good as well
Quoted 5 lines
c:\Users\lev\Projects\openvpn-build\msvc>set MODE=DEPS&& build.bat c:\Users\lev\Projects\openvpn-build\msvc>set MODE=OPENVPN&& build.bat
It depends on VS2017, maybe it is time to switch to VS2019.
travis-ci comes without VS installed. I'll figure out is it legal to install community edition or not
currently it already caught nasty bug
"rc" was removed by endlocal:
https://github.com/OpenVPN/openvpn-build/pull/152
Quoted 11 lines
Quoted 4 lines
travis-ci supports windows builds. I would like to add VS to travis-ci
That would be cool.
Quoted 1 line
--
-Lev
Signature · 1 line
-Lev
Am 18.07.19 um 11:35 schrieb Lev Stipakov:
Quoted 7 lines
From: Lev Stipakov <[email protected]...>
Commit fb4e8ab added variable-length array which is C99 feature and is not supported by Visual Studio.
This removes VLA and writes data directly into passed buffer.
After some confusion of the various buffer related function on my side, this looks good.
Your patch has been applied to the master branch.
(The code is not in 2.4, so no need to backport). Slightly tested with a "make check" run.
commit 2df27b2fa3932372075afd0db6b706a38e0a9dc3
Author: Lev Stipakov Date: Thu Jul 18 12:35:03 2019 +0300
crypto.c: fix Visual Studio build
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18676.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering