Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
library.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 12, 2012
1 parent 8eafe0b commit 4c4b5db
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion http.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion library.c
Expand Up @@ -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;
}
12 changes: 6 additions & 6 deletions main.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -374,10 +374,10 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
#endif

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);
}

openconnect_init_openssl();
Expand Down Expand Up @@ -609,7 +609,7 @@ int main(int argc, char **argv)
verbose = PRG_TRACE;
break;
case 'V':
printf(_("OpenConnect version %s\n"), openconnect_version);
printf(_("OpenConnect version %s\n"), openconnect_version_str);
exit(0);
case 'x':
vpninfo->xmlconfig = keep_config_arg();
Expand Down
2 changes: 1 addition & 1 deletion openconnect-internal.h
Expand Up @@ -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;

#endif /* __OPENCONNECT_INTERNAL_H__ */
2 changes: 1 addition & 1 deletion version.sh
Expand Up @@ -15,5 +15,5 @@ else
v="$v"-unknown
fi

echo "char openconnect_version[] = \"$v\";" > $1
echo "const char *openconnect_version_str = \"$v\";" > $1
echo "New version: $v"

0 comments on commit 4c4b5db

Please sign in to comment.