From b131717707ec6a5c91da313be1bc42a2267e873b Mon Sep 17 00:00:00 2001 From: pfg Date: Thu, 4 May 2017 14:48:57 +0000 Subject: MFC r317583: Fix some cases where an index was used before its limits check. Obtained from: DragonFlyBSD (git 799ba435) --- sys/dev/sound/pcm/feeder_matrix.c | 4 ++-- usr.bin/unexpand/unexpand.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/dev/sound/pcm/feeder_matrix.c b/sys/dev/sound/pcm/feeder_matrix.c index e59c124..5274ed4 100644 --- a/sys/dev/sound/pcm/feeder_matrix.c +++ b/sys/dev/sound/pcm/feeder_matrix.c @@ -750,8 +750,8 @@ feeder_matrix_oss_get_channel_order(struct pcmchan_matrix *m, tmpmap = 0x0000000000000000ULL; - for (i = 0; m->map[i].type != SND_CHN_T_MAX && - i < SND_CHN_OSS_MAX; i++) { + for (i = 0; i < SND_CHN_OSS_MAX && m->map[i].type != SND_CHN_T_MAX; + i++) { if ((1 << m->map[i].type) & ~SND_CHN_OSS_VALIDMASK) return (EINVAL); tmpmap |= diff --git a/usr.bin/unexpand/unexpand.c b/usr.bin/unexpand/unexpand.c index 1ef5db1..dcbd7fb 100644 --- a/usr.bin/unexpand/unexpand.c +++ b/usr.bin/unexpand/unexpand.c @@ -132,8 +132,8 @@ tabify(const char *curfile) tabstops[0]; continue; } else { - for (n = 0; tabstops[n] - 1 < dcol && - n < nstops; n++) + for (n = 0; n < nstops && + tabstops[n] - 1 < dcol; n++) ; if (n < nstops - 1 && tabstops[n] - 1 < limit) { dcol = tabstops[n]; @@ -154,7 +154,7 @@ tabify(const char *curfile) tabstops[0]; } } else { - for (n = 0; tabstops[n] - 1 < ocol && n < nstops; n++) + for (n = 0; n < nstops && tabstops[n] - 1 < ocol; n++) ; while (ocol < dcol && n < nstops && ocol < limit) { putwchar('\t'); -- cgit v1.1