Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix arithmetic on void pointers in cstp.c
This is a gccism and not portable. And could have been dereferencing an
unaligned pointer too. Thanks to Florian Wobbe for pointing it out.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Oct 28, 2011
1 parent bd6dd65 commit 8d753ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cstp.c
Expand Up @@ -439,9 +439,11 @@ int cstp_reconnect(struct openconnect_info *vpninfo)
return 0;
}

static int inflate_and_queue_packet(struct openconnect_info *vpninfo, void *buf, int len)
static int inflate_and_queue_packet(struct openconnect_info *vpninfo,
unsigned char *buf, int len)
{
struct pkt *new = malloc(sizeof(struct pkt) + vpninfo->mtu);
uint32_t pkt_sum;

if (!new)
return -ENOMEM;
Expand All @@ -466,7 +468,10 @@ static int inflate_and_queue_packet(struct openconnect_info *vpninfo, void *buf,
vpninfo->inflate_adler32 = adler32(vpninfo->inflate_adler32,
new->data, new->len);

if (vpninfo->inflate_adler32 != ntohl( *(uint32_t *) (buf + len - 4) )) {
pkt_sum = buf[len - 1] | (buf[len - 2] << 8) |
(buf[len - 3] << 16) | (buf[len - 4] << 24);

if (vpninfo->inflate_adler32 != pkt_sum) {
vpninfo->quit_reason = "Compression (inflate) adler32 failure";
}

Expand Down

0 comments on commit 8d753ec

Please sign in to comment.