Skip to content

Commit f2d849b

Browse files
committed
pppd/tty.c: Use unsigned constants for ACCM calculations
Use unsigned constants to avoid integer overflows when shifting, and because xmit_accm[] is an array of unsigned values. Signed-off-by: Paul Mackerras <[email protected]>
1 parent efb2667 commit f2d849b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pppd/tty.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ setescape(char **argv)
418418
ppp_option_error("can't escape character 0x%x", n);
419419
ret = 0;
420420
} else
421-
xmit_accm[n >> 5] |= 1 << (n & 0x1F);
421+
xmit_accm[n >> 5] |= 1U << (n & 0x1F);
422422
while (*p == ',' || *p == ' ')
423423
++p;
424424
}
@@ -435,7 +435,7 @@ printescape(struct option *opt, void (*printer)(void *, char *, ...), void *arg)
435435
for (n = 0; n < 256; ++n) {
436436
if (n == 0x7d)
437437
n += 2; /* skip 7d, 7e */
438-
if (xmit_accm[n >> 5] & (1 << (n & 0x1f))) {
438+
if (xmit_accm[n >> 5] & (1U << (n & 0x1f))) {
439439
if (!first)
440440
printer(arg, ",");
441441
else
@@ -454,7 +454,7 @@ void tty_init(void)
454454
{
455455
ppp_add_notify(NF_PID_CHANGE, maybe_relock, 0);
456456
the_channel = &tty_channel;
457-
xmit_accm[3] = 0x60000000;
457+
xmit_accm[3] = 0x60000000U;
458458
}
459459

460460
/*

0 commit comments

Comments
 (0)