factotum/authsrv: fix padding for mschap on amd64, use constants for structure sizes
This commit is contained in:
parent
240ba73770
commit
e42981dfcf
3 changed files with 15 additions and 10 deletions
|
@ -100,6 +100,7 @@ struct OChapreply
|
||||||
char uid[ANAMELEN];
|
char uid[ANAMELEN];
|
||||||
char resp[OMD5LEN];
|
char resp[OMD5LEN];
|
||||||
};
|
};
|
||||||
|
#define OCHAPREPLYLEN (1+ANAMELEN+OMD5LEN)
|
||||||
|
|
||||||
struct OMSchapreply
|
struct OMSchapreply
|
||||||
{
|
{
|
||||||
|
@ -107,6 +108,7 @@ struct OMSchapreply
|
||||||
char LMresp[24]; /* Lan Manager response */
|
char LMresp[24]; /* Lan Manager response */
|
||||||
char NTresp[24]; /* NT response */
|
char NTresp[24]; /* NT response */
|
||||||
};
|
};
|
||||||
|
#define OMSCHAPREPLYLEN (ANAMELEN+24+24)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert to/from wire format
|
* convert to/from wire format
|
||||||
|
|
|
@ -695,7 +695,7 @@ mschap(Ticketreq *tr)
|
||||||
/*
|
/*
|
||||||
* get chap reply
|
* get chap reply
|
||||||
*/
|
*/
|
||||||
if(readn(0, &reply, sizeof(reply)) < 0)
|
if(readn(0, &reply, OMSCHAPREPLYLEN) < 0)
|
||||||
exits(0);
|
exits(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,9 @@ enum {
|
||||||
MShashlen = 16,
|
MShashlen = 16,
|
||||||
MSchallen = 8,
|
MSchallen = 8,
|
||||||
MSresplen = 24,
|
MSresplen = 24,
|
||||||
|
|
||||||
|
Chapreplylen = MD5LEN+1,
|
||||||
|
MSchapreplylen = 24+24,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int dochal(State *s);
|
static int dochal(State *s);
|
||||||
|
@ -198,10 +201,10 @@ chapwrite(Fsstate *fss, void *va, uint n)
|
||||||
default:
|
default:
|
||||||
return failure(fss, "chap internal botch");
|
return failure(fss, "chap internal botch");
|
||||||
case AuthChap:
|
case AuthChap:
|
||||||
if(n != sizeof(*cr))
|
if(n < Chapreplylen)
|
||||||
return failure(fss, "did not get Chapreply");
|
return failure(fss, "did not get Chapreply");
|
||||||
cr = (Chapreply*)va;
|
cr = (Chapreply*)va;
|
||||||
nreply = sizeof(*ocr);
|
nreply = OCHAPREPLYLEN;
|
||||||
memset(reply, 0, nreply);
|
memset(reply, 0, nreply);
|
||||||
ocr = (OChapreply*)reply;
|
ocr = (OChapreply*)reply;
|
||||||
strecpy(ocr->uid, ocr->uid+sizeof(ocr->uid), s->user);
|
strecpy(ocr->uid, ocr->uid+sizeof(ocr->uid), s->user);
|
||||||
|
@ -209,17 +212,17 @@ chapwrite(Fsstate *fss, void *va, uint n)
|
||||||
memmove(ocr->resp, cr->resp, sizeof(ocr->resp));
|
memmove(ocr->resp, cr->resp, sizeof(ocr->resp));
|
||||||
break;
|
break;
|
||||||
case AuthMSchap:
|
case AuthMSchap:
|
||||||
if(n < sizeof(*mcr))
|
if(n < MSchapreplylen)
|
||||||
return failure(fss, "did not get MSchapreply");
|
return failure(fss, "did not get MSchapreply");
|
||||||
if(n > sizeof(reply)+sizeof(*mcr)-sizeof(*omcr))
|
if(n > sizeof(reply)+MSchapreplylen-OMSCHAPREPLYLEN)
|
||||||
return failure(fss, "MSchapreply too long");
|
return failure(fss, "MSchapreply too long");
|
||||||
mcr = (MSchapreply*)va;
|
mcr = (MSchapreply*)va;
|
||||||
nreply = n+sizeof(*omcr)-sizeof(*mcr);
|
nreply = n+OMSCHAPREPLYLEN-MSchapreplylen;
|
||||||
memset(reply, 0, nreply);
|
memset(reply, 0, nreply);
|
||||||
omcr = (OMSchapreply*)reply;
|
omcr = (OMSchapreply*)reply;
|
||||||
strecpy(omcr->uid, omcr->uid+sizeof(omcr->uid), s->user);
|
strecpy(omcr->uid, omcr->uid+sizeof(omcr->uid), s->user);
|
||||||
memmove(omcr->LMresp, mcr->LMresp, sizeof(omcr->LMresp));
|
memmove(omcr->LMresp, mcr->LMresp, sizeof(omcr->LMresp));
|
||||||
memmove(omcr->NTresp, mcr->NTresp, n+sizeof(mcr->NTresp)-sizeof(*mcr));
|
memmove(omcr->NTresp, mcr->NTresp, n+sizeof(mcr->NTresp)-MSchapreplylen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(doreply(s, reply, nreply) < 0)
|
if(doreply(s, reply, nreply) < 0)
|
||||||
|
@ -282,7 +285,7 @@ dochal(State *s)
|
||||||
|
|
||||||
memset(&s->tr, 0, sizeof(s->tr));
|
memset(&s->tr, 0, sizeof(s->tr));
|
||||||
s->tr.type = s->astype;
|
s->tr.type = s->astype;
|
||||||
safecpy(s->tr.authdom, dom, sizeof s->tr.authdom);
|
safecpy(s->tr.authdom, dom, sizeof(s->tr.authdom));
|
||||||
safecpy(s->tr.hostid, user, sizeof(s->tr.hostid));
|
safecpy(s->tr.hostid, user, sizeof(s->tr.hostid));
|
||||||
convTR2M(&s->tr, trbuf);
|
convTR2M(&s->tr, trbuf);
|
||||||
|
|
||||||
|
@ -488,7 +491,7 @@ domschap(char *passwd, uchar chal[MSchallen], uchar *resp, int resplen)
|
||||||
MSchapreply *r;
|
MSchapreply *r;
|
||||||
|
|
||||||
r = (MSchapreply*)resp;
|
r = (MSchapreply*)resp;
|
||||||
if(resplen < sizeof(*r))
|
if(resplen < MSchapreplylen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
lmhash(hash, passwd);
|
lmhash(hash, passwd);
|
||||||
|
@ -497,7 +500,7 @@ domschap(char *passwd, uchar chal[MSchallen], uchar *resp, int resplen)
|
||||||
nthash(hash, passwd);
|
nthash(hash, passwd);
|
||||||
mschalresp((uchar*)r->NTresp, hash, chal);
|
mschalresp((uchar*)r->NTresp, hash, chal);
|
||||||
|
|
||||||
return sizeof(*r);
|
return MSchapreplylen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue