if (packetAliasMSS < mssVal)
{
int accumulate = mssVal;
+ int accnetorder = 0 ;
accumulate -= packetAliasMSS;
*mssPtr = htons(packetAliasMSS);
- ADJUST_CHECKSUM(accumulate, tc->th_sum);
+ accnetorder = htons(accumulate);
+ ADJUST_CHECKSUM(accnetorder, tc->th_sum);
}
option = optionEnd;
p->type = np;
p->len = ntohs(gen->len);
- if (p->len == 0 || p->len > tlen) {
+ if (p->len < sizeof(struct isakmp_gen) || p->len > tlen) {
plog(LLV_DEBUG, LOCATION, NULL,
"invalid length of payload\n");
vfree(result);
#ifdef IKE_NAT_T
if (natd_type) {
- if ((iph1->natt_flags & NATT_TYPE_MASK) == natt_type_apple) {
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, natd_type);
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
- } else {
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, natd_type);
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, ISAKMP_NPTYPE_NONE);
- }
+ if (iph1->local_natd)
+ p = set_isakmp_payload(p, iph1->local_natd, natd_type);
+ if (iph1->remote_natd)
+ p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
}
#endif
#ifdef IKE_NAT_T
if (nattvid) {
p = set_isakmp_payload(p, nattvid, iph1->natd_payload_type);
- if ((iph1->natt_flags & NATT_TYPE_MASK) == natt_type_apple) {
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, iph1->natd_payload_type);
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
- } else {
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, iph1->natd_payload_type);
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, ISAKMP_NPTYPE_NONE);
- }
+ if (iph1->local_natd)
+ p = set_isakmp_payload(p, iph1->local_natd, iph1->natd_payload_type);
+ if (iph1->remote_natd)
+ p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
}
#endif
break;
#ifdef IKE_NAT_T
if (nattvid) {
p = set_isakmp_payload(p, nattvid, iph1->natd_payload_type);
- if ((iph1->natt_flags & NATT_TYPE_MASK) == natt_type_apple) {
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, iph1->natd_payload_type);
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
- } else {
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, iph1->natd_payload_type);
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, ISAKMP_NPTYPE_NONE);
- }
+ if (iph1->local_natd)
+ p = set_isakmp_payload(p, iph1->local_natd, iph1->natd_payload_type);
+ if (iph1->remote_natd)
+ p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
}
#endif
#ifdef IKE_NAT_T
if (natd_type) {
- if ((iph1->natt_flags & NATT_TYPE_MASK) == natt_type_apple) {
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, natd_type);
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
- } else {
- if (iph1->remote_natd)
- p = set_isakmp_payload(p, iph1->remote_natd, natd_type);
- if (iph1->local_natd)
- p = set_isakmp_payload(p, iph1->local_natd, ISAKMP_NPTYPE_NONE);
- }
+ if (iph1->local_natd)
+ p = set_isakmp_payload(p, iph1->local_natd, natd_type);
+ if (iph1->remote_natd)
+ p = set_isakmp_payload(p, iph1->remote_natd, ISAKMP_NPTYPE_NONE);
}
#endif
error = 0;
char **av;
{
int error;
-
+
if (geteuid() != 0) {
errx(1, "must be root to invoke this program.");
/* NOTREACHED*/
/* SKEYID */
switch(iph1->approval->authmethod) {
- case OAKLEY_ATTR_AUTH_METHOD_PSKEY:
- /* if we have a preshared key defined, just use it */
- if (iph1->rmconf->shared_secret) {
-
- switch (iph1->rmconf->secrettype) {
- case SECRETTYPE_KEY:
- iph1->authstr = getpsk(iph1->rmconf->shared_secret->v, iph1->rmconf->shared_secret->l-1);
- break;
- case SECRETTYPE_KEYCHAIN:
- iph1->authstr = getpskfromkeychain(iph1->rmconf->shared_secret->v);
- break;
- case SECRETTYPE_USE:
- default:
- iph1->authstr = vdup(iph1->rmconf->shared_secret);
- }
-
- }
+ case OAKLEY_ATTR_AUTH_METHOD_PSKEY:
+ if (iph1->nonce_p == NULL) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "no nonce payload received from peer.\n");
+ goto end;
+ }
+ /* if we have a preshared key defined, just use it */
+ if (iph1->rmconf->shared_secret) {
+
+ switch (iph1->rmconf->secrettype) {
+ case SECRETTYPE_KEY:
+ iph1->authstr = getpsk(iph1->rmconf->shared_secret->v, iph1->rmconf->shared_secret->l-1);
+ break;
+ case SECRETTYPE_KEYCHAIN:
+ iph1->authstr = getpskfromkeychain(iph1->rmconf->shared_secret->v);
+ break;
+ case SECRETTYPE_USE:
+ default:
+ iph1->authstr = vdup(iph1->rmconf->shared_secret);
+ }
+
+ }
else if (iph1->etype != ISAKMP_ETYPE_IDENT) {
iph1->authstr = getpskbyname(iph1->id_p);
if (iph1->authstr == NULL) {
#ifdef HAVE_GSSAPI
case OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB:
#endif
+ if (iph1->nonce_p == NULL) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "no nonce payload received from peer.\n");
+ goto end;
+ }
len = iph1->nonce->l + iph1->nonce_p->l;
buf = vmalloc(len);
if (buf == NULL) {