Commit 4c4b5dbc authored by David Woodhouse's avatar David Woodhouse

Export openconnect_version as a pointer rather than an array

Otherwise, the binary seems to *know* the length of the string that it
expected to be in the library, and when bitching of a mismatch it still
truncates the library version to the length that it *expected* the library
version string to be.

Change the name of it to 'openconnect_version_str' at the same time as we
change the datatype, to avoid crashes when linking against an older/newer
Signed-off-by: default avatarDavid Woodhouse <>
parent 8eafe0b0
......@@ -869,7 +869,7 @@ char *openconnect_create_useragent(const char *base)
char *uagent;
if (asprintf(&uagent, "%s %s", base, openconnect_version) < 0)
if (asprintf(&uagent, "%s %s", base, openconnect_version_str) < 0)
return NULL;
return uagent;
......@@ -211,5 +211,5 @@ void openconnect_set_cancel_fd (struct openconnect_info *vpninfo, int fd)
const char *openconnect_get_version (void)
return openconnect_version;
return openconnect_version_str;
......@@ -62,9 +62,9 @@ static int validate_peer_cert(void *_vpninfo,
/* A sanity check that the openconnect executable is running against a
library of the same version */
#define openconnect_version openconnect_binary_version
#define openconnect_version_str openconnect_binary_version
#include "version.c"
#undef openconnect_version
#undef openconnect_version_str
int verbose = PRG_INFO;
int background;
......@@ -170,7 +170,7 @@ static void helpmessage(void)
static void usage(void)
printf(_("Usage: openconnect [options] <server>\n"));
printf(_("Open client for Cisco AnyConnect VPN, version %s\n\n"), openconnect_version);
printf(_("Open client for Cisco AnyConnect VPN, version %s\n\n"), openconnect_version_str);
printf(" --config=CONFIGFILE %s\n", _("Read options from config file"));
printf(" -b, --background %s\n", _("Continue in background after startup"));
printf(" --pid-file=PIDFILE %s\n", _("Write the daemons pid to this file"));
......@@ -374,10 +374,10 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
if (strcmp(openconnect_version, openconnect_binary_version)) {
if (strcmp(openconnect_version_str, openconnect_binary_version)) {
fprintf(stderr, _("WARNING: This version of openconnect is %s but\n"
" the libopenconnect library is %s\n"),
openconnect_binary_version, openconnect_version);
openconnect_binary_version, openconnect_version_str);
......@@ -609,7 +609,7 @@ int main(int argc, char **argv)
verbose = PRG_TRACE;
case 'V':
printf(_("OpenConnect version %s\n"), openconnect_version);
printf(_("OpenConnect version %s\n"), openconnect_version_str);
case 'x':
vpninfo->xmlconfig = keep_config_arg();
......@@ -319,6 +319,6 @@ int generate_securid_tokencodes(struct openconnect_info *vpninfo);
int add_securid_pin(char *token, char *pin);
/* version.c */
extern char openconnect_version[];
extern const char *openconnect_version_str;
......@@ -15,5 +15,5 @@ else
echo "char openconnect_version[] = \"$v\";" > $1
echo "const char *openconnect_version_str = \"$v\";" > $1
echo "New version: $v"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment