Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Apr 2017 06:41:51 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317583 - in head: sys/dev/sound/pcm usr.bin/unexpand
Message-ID:  <201704290641.v3T6fpge098182@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sat Apr 29 06:41:51 2017
New Revision: 317583
URL: https://svnweb.freebsd.org/changeset/base/317583

Log:
  Fix some cases where an index was used before its limits check.
  
  Obtained from:	DragonFlyBSD (git 799ba435)
  MFC after:	5 days

Modified:
  head/sys/dev/sound/pcm/feeder_matrix.c
  head/usr.bin/unexpand/unexpand.c

Modified: head/sys/dev/sound/pcm/feeder_matrix.c
==============================================================================
--- head/sys/dev/sound/pcm/feeder_matrix.c	Sat Apr 29 06:33:37 2017	(r317582)
+++ head/sys/dev/sound/pcm/feeder_matrix.c	Sat Apr 29 06:41:51 2017	(r317583)
@@ -750,8 +750,8 @@ feeder_matrix_oss_get_channel_order(stru
 
 	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 |=

Modified: head/usr.bin/unexpand/unexpand.c
==============================================================================
--- head/usr.bin/unexpand/unexpand.c	Sat Apr 29 06:33:37 2017	(r317582)
+++ head/usr.bin/unexpand/unexpand.c	Sat Apr 29 06:41:51 2017	(r317583)
@@ -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');



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704290641.v3T6fpge098182>