Re: [Openvpn-devel] [PATCH] crypto.c: fix Visual Studio build
Am 18.07.19 um 11:35 schrieb Lev Stipakov: > From: Lev Stipakov > > 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. Acked-By: Arne Schwabe ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] crypto.c: fix Visual Studio build
On 18/07/2019 14:20, Lev Stipakov wrote: > Hi, > > >> 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: > >> +const int len = BCAP(key); >> > > and then pass it to rand_bytes: > Ok, that sounds good, thanks! > >>> +if (!rand_bytes(BEND(key), len)) > > -- Antonio Quartulli ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] crypto.c: fix Visual Studio build
Hi, > 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: > +const int len = BCAP(key); > and then pass it to rand_bytes: > > +if (!rand_bytes(BEND(key), len)) -- -Lev ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] crypto.c: fix Visual Studio build
Hi, On 18/07/2019 11:35, Lev Stipakov wrote: > From: Lev Stipakov > > 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 > --- > src/openvpn/crypto.c | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c > index 69877d1..8bf33e7 100644 > --- a/src/openvpn/crypto.c > +++ b/src/openvpn/crypto.c > @@ -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, > { > msg(M_WARN, "ERROR: could not generate random key"); > return false; > } > -buf_write(key, rand, BCAP(key)); > + > +buf_inc_len(key, len); > + > return true; > } > > -- Antonio Quartulli ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel