summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/pap.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-11-26 22:44:45 +0000
committerbrian <brian@FreeBSD.org>1999-11-26 22:44:45 +0000
commitae1dbed1c2c8e2f18352af8df3e30ad5b6132458 (patch)
treea46a68afd7e77ac01569f4972eb491b995d8a3ae /usr.sbin/ppp/pap.c
parentf0003f34563b650e7d94531962fc8f09b2a5f5ec (diff)
downloadFreeBSD-src-ae1dbed1c2c8e2f18352af8df3e30ad5b6132458.zip
FreeBSD-src-ae1dbed1c2c8e2f18352af8df3e30ad5b6132458.tar.gz
Allow extended pap success messages by believing in the PAP headers
length field rather than the one byte message length field embedded in the packet. This steps slightly outside of the protocol boundaries, but should not cause any problems. Limitation noted by: Simon Winwood <simon@winwood.org>
Diffstat (limited to 'usr.sbin/ppp/pap.c')
-rw-r--r--usr.sbin/ppp/pap.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c
index f283d3a..e857d0a 100644
--- a/usr.sbin/ppp/pap.c
+++ b/usr.sbin/ppp/pap.c
@@ -114,7 +114,12 @@ SendPapCode(struct authinfo *authp, int code, const char *message)
bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_PAPOUT);
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
cp = MBUF_CTOP(bp) + sizeof(struct fsmheader);
- *cp++ = mlen;
+ /*
+ * If our message is longer than 255 bytes, truncate the length to
+ * 255 and send the entire message anyway. Maybe the other end will
+ * display it... (see pap_Input() !)
+ */
+ *cp++ = mlen > 255 ? 255 : mlen;
memcpy(cp, message, mlen);
log_Printf(LogPHASE, "Pap Output: %s\n", papcodes[code]);
@@ -158,6 +163,8 @@ pap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
struct physical *p = link2physical(l);
struct authinfo *authp = &p->dl->pap;
u_char nlen, klen, *key;
+ const char *txt;
+ int txtlen;
if (p == NULL) {
log_Printf(LogERROR, "pap_Input: Not a physical link - dropped\n");
@@ -197,11 +204,27 @@ pap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
if (bp) {
bp = mbuf_Read(bp, &nlen, 1);
- bp = auth_ReadName(authp, bp, nlen);
+ if (authp->in.hdr.code == PAP_ACK) {
+ /*
+ * Don't restrict the length of our acknowledgement freetext to
+ * nlen (a one-byte length). Show the rest of the ack packet
+ * instead. This isn't really part of the protocol.....
+ */
+ bp = mbuf_Contiguous(bp);
+ txt = MBUF_CTOP(bp);
+ txtlen = mbuf_Length(bp);
+ } else {
+ bp = auth_ReadName(authp, bp, nlen);
+ txt = authp->in.name;
+ txtlen = strlen(authp->in.name);
+ }
+ } else {
+ txt = "";
+ txtlen = 0;
}
- log_Printf(LogPHASE, "Pap Input: %s (%s)\n",
- papcodes[authp->in.hdr.code], authp->in.name);
+ log_Printf(LogPHASE, "Pap Input: %s (%.*s)\n",
+ papcodes[authp->in.hdr.code], txtlen, txt);
switch (authp->in.hdr.code) {
case PAP_REQUEST:
OpenPOWER on IntegriCloud