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 <lev@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <
1563442503-11119-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
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;
}