Date: Sat, 17 Nov 2001 18:29:17 -0800 (PST) From: Archie Cobbs <archie@dellroad.org> To: Trond Davidsen <trond.davidsen@ii.uib.no> Cc: freebsd-net@FreeBSD.ORG Subject: Re: Mpd and pap authentication Message-ID: <200111180229.fAI2THw01360@arch20m.dellroad.org> In-Reply-To: <3BF6D769.9000902@ii.uib.no> "from Trond Davidsen at Nov 17, 2001 10:32:25 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Trond Davidsen writes: > there seems to be a bug in mpd in the handling of PAP > Authenticate-Ack's. RFC 1334 section 2.2.2 specifies the packet format > to look something like the following: > > | Code | Identifier | Length | Msg-Length | Message | > > Mpd leaves out the Msg-Length field, which confuses at least one ppp > implementation, namely pppd (used in FreeBSD, Linux, MacOSX, ...). Wacky.. :-) Try the patch below.. and thanks!! -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com Index: pap.c =================================================================== RCS file: /home/cvs/archie/mpd/src/pap.c,v retrieving revision 1.2 diff -u -r1.2 pap.c --- pap.c 2001/04/12 17:03:33 1.2 +++ pap.c 2001/11/18 02:28:21 @@ -29,7 +29,8 @@ */ static void PapSendRequest(PapInfo pap); - static void PapOutput(u_int code, u_int id, const u_char *buf, int len); + static void PapOutput(u_int code, u_int id, + const u_char *buf, int len, int add_len); static void PapTimeout(void *ptr); static char *PapCode(int code); @@ -104,7 +105,7 @@ memcpy(pkt + 1 + name_len + 1, auth.password, pass_len); /* Send it off */ - PapOutput(PAP_REQUEST, pap->next_id++, pkt, 1 + name_len + 1 + pass_len); + PapOutput(PAP_REQUEST, pap->next_id++, pkt, 1 + name_len + 1 + pass_len, 0); Freee(pkt); } @@ -199,14 +200,15 @@ whyFail = AUTH_FAIL_INVALID_LOGIN; badRequest: failMesg = AuthFailMsg(PROTO_PAP, 0, whyFail); - PapOutput(PAP_NAK, php.id, failMesg, strlen(failMesg)); + PapOutput(PAP_NAK, php.id, failMesg, strlen(failMesg), 1); AuthFinish(AUTH_PEER_TO_SELF, FALSE, NULL); break; } /* Login accepted */ Log(LG_AUTH, (" Response is valid")); - PapOutput(PAP_ACK, php.id, AUTH_MSG_WELCOME, strlen(AUTH_MSG_WELCOME)); + PapOutput(PAP_ACK, php.id, + AUTH_MSG_WELCOME, strlen(AUTH_MSG_WELCOME), 1); AuthFinish(AUTH_PEER_TO_SELF, TRUE, &auth); } break; @@ -255,14 +257,15 @@ */ static void -PapOutput(u_int code, u_int id, const u_char *buf, int len) +PapOutput(u_int code, u_int id, const u_char *buf, int len, int add_len) { struct fsmheader lh; Mbuf bp; int plen; /* Setup header */ - plen = sizeof(lh) + len; + add_len = !!add_len; + plen = sizeof(lh) + add_len + len; lh.id = id; lh.code = code; lh.length = htons(plen); @@ -270,7 +273,9 @@ /* Build packet */ bp = mballoc(MB_AUTH, plen); memcpy(MBDATA(bp), &lh, sizeof(lh)); - memcpy(MBDATA(bp) + sizeof(lh), buf, len); + if (add_len) + *(MBDATA(bp) + sizeof(lh)) = (u_char)len; + memcpy(MBDATA(bp) + sizeof(lh) + add_len, buf, len); /* Send it out */ Log(LG_AUTH, ("[%s] PAP: sending %s", lnk->name, PapCode(code))); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111180229.fAI2THw01360>