|
|||||||||||
|
sparc/2918: Alignment problem in ppp when using 'enable lqr'.
From: <fanch(at)enki.dyndns.org>
Date: Sat Sep 14 2002 - 10:36:23 EDT
System : OpenBSD 3.1 Architecture: OpenBSD.sparc Machine : sparcstation 1+LcpDecodeConfig(), access to cp are not protected against alignment problems. I corrected the problem in my lcp.c (3.1 patch branch) by using 2 intermediate variables (sorry for my English, I'm French), diff follows :
-/* for received LQRs */
-struct lqrreq {
- u_char type;
- u_char length;
- u_short proto; /* Quality protocol */
- u_int32_t period; /* Reporting interval */
-};
-
static int LcpLayerUp(struct fsm *); static void LcpLayerDown(struct fsm *); static void LcpLayerStart(struct fsm *); @@ -621,9 +613,8 @@
/* Deal with incoming PROTO_LCP */
- u_int32_t magic, accmap; + u_int32_t magic, accmap, period; u_short mru, phmtu, maxmtu, maxmru, wantmtu, wantmru, proto;- struct lqrreq *req;
char request[20], desc[22];
break;
case TY_QUALPROTO:
- req = (struct lqrreq *)cp;
+ ua_ntohs(cp + 2, &proto);
+ ua_ntohl(cp + 4, &period);
log_Printf(LogLCP, "%s proto %x, interval %lums\n",
- request, ntohs(req->proto), (u_long)ntohl(req->period) * 10);
+ request, proto,
+ (u_long)period * 10);
switch (mode_type) {
case MODE_REQ:
- if (ntohs(req->proto) != PROTO_LQR || !IsAccepted(lcp->cfg.lqr))
+ if (proto != PROTO_LQR || !IsAccepted(lcp->cfg.lqr))
goto reqreject;
else {
- lcp->his_lqrperiod = ntohl(req->period);
+ lcp->his_lqrperiod = period;
if (lcp->his_lqrperiod < MIN_LQRPERIOD * 100)
lcp->his_lqrperiod = MIN_LQRPERIOD * 100;
- req->period = htonl(lcp->his_lqrperiod);
+ ua_htonl(&(lcp->his_lqrperiod), cp + 4);
memcpy(dec->ackend, cp, length);
dec->ackend += length;
}
>Release-Note:
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:36 EDT |
||||||||||
|
|||||||||||