From owner-svn-src-head@FreeBSD.ORG Thu Aug 21 02:40:35 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F6D1301; Thu, 21 Aug 2014 02:40:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E4E22347B; Thu, 21 Aug 2014 02:40:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7L2eYJD076103; Thu, 21 Aug 2014 02:40:34 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7L2eYju076100; Thu, 21 Aug 2014 02:40:34 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201408210240.s7L2eYju076100@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 21 Aug 2014 02:40:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270256 - in head: bin/ed libexec/rtld-elf usr.bin/mail X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2014 02:40:35 -0000 Author: pfg Date: Thu Aug 21 02:40:33 2014 New Revision: 270256 URL: http://svnweb.freebsd.org/changeset/base/270256 Log: Always check the limits of array index variables before using them. Obtained from: DragonFlyBSD MFC after: 1 week Modified: head/bin/ed/cbc.c head/libexec/rtld-elf/libmap.c head/usr.bin/mail/edit.c Modified: head/bin/ed/cbc.c ============================================================================== --- head/bin/ed/cbc.c Thu Aug 21 01:07:27 2014 (r270255) +++ head/bin/ed/cbc.c Thu Aug 21 02:40:33 2014 (r270256) @@ -237,7 +237,7 @@ expand_des_key(char *obuf, char *kbuf) /* * now translate it, bombing on any illegal hex digit */ - for (i = 0; kbuf[i] && i < 16; i++) + for (i = 0; i < 16 && kbuf[i]; i++) if ((nbuf[i] = hex_to_binary((int) kbuf[i], 16)) == -1) des_error("bad hex digit in key"); while (i < 16) Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Thu Aug 21 01:07:27 2014 (r270255) +++ head/libexec/rtld-elf/libmap.c Thu Aug 21 02:40:33 2014 (r270256) @@ -216,14 +216,14 @@ lmc_parse(char *lm_p, size_t lm_len) p = NULL; while (cnt < lm_len) { i = 0; - while (lm_p[cnt] != '\n' && cnt < lm_len && + while (cnt < lm_len && lm_p[cnt] != '\n' && i < sizeof(line) - 1) { line[i] = lm_p[cnt]; cnt++; i++; } line[i] = '\0'; - while (lm_p[cnt] != '\n' && cnt < lm_len) + while (cnt < lm_len && lm_p[cnt] != '\n') cnt++; /* skip over nl */ cnt++; Modified: head/usr.bin/mail/edit.c ============================================================================== --- head/usr.bin/mail/edit.c Thu Aug 21 01:07:27 2014 (r270255) +++ head/usr.bin/mail/edit.c Thu Aug 21 02:40:33 2014 (r270256) @@ -81,7 +81,7 @@ edit1(int *msgvec, int type) /* * Deal with each message to be edited . . . */ - for (i = 0; msgvec[i] && i < msgCount; i++) { + for (i = 0; i < msgCount && msgvec[i]; i++) { sig_t sigint; if (i > 0) {