Skip to content

Commit

Permalink
Fix asprintf() handling in openconnect_passphrase_from_fsid()
Browse files Browse the repository at this point in the history
It returns -1 on error. Not non-zero. We were always returning -ENOMEM but
nobody cared; if this fails they'll just ignore it and let us ask the user
for the passphrase anyway.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jul 31, 2014
1 parent 45f8f22 commit 598a08c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ssl.c
Expand Up @@ -379,7 +379,7 @@ int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
err = -errno;
vpn_progress(vpninfo, PRG_ERR, _("statvfs: %s\n"),
strerror(errno));
} else if (asprintf(&vpninfo->cert_password, "%lx", buf.f_fsid))
} else if (asprintf(&vpninfo->cert_password, "%lx", buf.f_fsid) == -1)
err = -ENOMEM;

if (sslkey != vpninfo->sslkey)
Expand Down Expand Up @@ -428,7 +428,7 @@ int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
if (!success)
return -EIO;

if (asprintf(&vpninfo->cert_password, "%lx", serial))
if (asprintf(&vpninfo->cert_password, "%lx", serial) == -1)
return -ENOMEM;

return 0;
Expand All @@ -450,7 +450,7 @@ int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
} else {
fsid64 = ((unsigned long long)fsid[0] << 32) | fsid[1];

if (asprintf(&vpninfo->cert_password, "%llx", fsid64))
if (asprintf(&vpninfo->cert_password, "%llx", fsid64) == -1)
err = -ENOMEM;
}

Expand Down

0 comments on commit 598a08c

Please sign in to comment.