Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh PR/50747: David Binderman: check bounds before deref...



details:   https://anonhg.NetBSD.org/src/rev/c9311a456b7b
branches:  trunk
changeset: 813565:c9311a456b7b
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 03 05:26:16 2016 +0000

description:
PR/50747: David Binderman: check bounds before dereference.
While here add some continues before semicolons.

diffstat:

 bin/ksh/vi.c |  53 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 28 insertions(+), 25 deletions(-)

diffs (144 lines):

diff -r c2305f4be01f -r c9311a456b7b bin/ksh/vi.c
--- a/bin/ksh/vi.c      Wed Feb 03 05:18:58 2016 +0000
+++ b/bin/ksh/vi.c      Wed Feb 03 05:26:16 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vi.c,v 1.12 2011/06/22 03:56:17 mrg Exp $      */
+/*     $NetBSD: vi.c,v 1.13 2016/02/03 05:26:16 christos Exp $ */
 
 /*
  *     vi command editing
@@ -9,7 +9,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: vi.c,v 1.12 2011/06/22 03:56:17 mrg Exp $");
+__RCSID("$NetBSD: vi.c,v 1.13 2016/02/03 05:26:16 christos Exp $");
 #endif
 
 #include "config.h"
@@ -835,7 +835,7 @@
                                                (cmd[1]=='w' || cmd[1]=='W') &&
                                                !isspace((unsigned char)es->cbuf[es->cursor])) {
                                        while (isspace((unsigned char)es->cbuf[--ncursor]))
-                                               ;
+                                               continue;
                                        ncursor++;
                                }
                                if (ncursor > es->cursor) {
@@ -865,7 +865,7 @@
                        if (es->linelen != 0)
                                es->cursor++;
                        while (putbuf(ybuf, yanklen, 0) == 0 && --argcnt > 0)
-                               ;
+                               continue;
                        if (es->cursor != 0)
                                es->cursor--;
                        if (argcnt != 0)
@@ -1572,15 +1572,16 @@
        ncursor = es->cursor;
        while (ncursor < es->linelen && argcnt--) {
                if (is_wordch(es->cbuf[ncursor]))
-                       while (is_wordch(es->cbuf[ncursor]) &&
-                                       ncursor < es->linelen)
+                       while (ncursor < es->linelen &&
+                           is_wordch(es->cbuf[ncursor]))
                                ncursor++;
                else if (!isspace((unsigned char)es->cbuf[ncursor]))
-                       while (!is_wordch(es->cbuf[ncursor]) &&
-                                       !isspace((unsigned char)es->cbuf[ncursor]) &&
-                                       ncursor < es->linelen)
+                       while (ncursor < es->linelen &&
+                           !is_wordch(es->cbuf[ncursor]) &&
+                           !isspace((unsigned char)es->cbuf[ncursor]))
                                ncursor++;
-               while (isspace((unsigned char)es->cbuf[ncursor]) && ncursor < es->linelen)
+               while (ncursor < es->linelen &&
+                   isspace((unsigned char)es->cbuf[ncursor]))
                        ncursor++;
        }
        return ncursor;
@@ -1595,17 +1596,17 @@
        ncursor = es->cursor;
        while (ncursor > 0 && argcnt--) {
                while (--ncursor > 0 && isspace((unsigned char)es->cbuf[ncursor]))
-                       ;
+                       continue;
                if (ncursor > 0) {
                        if (is_wordch(es->cbuf[ncursor]))
                                while (--ncursor >= 0 &&
                                   is_wordch(es->cbuf[ncursor]))
-                                       ;
+                                       continue;
                        else
                                while (--ncursor >= 0 &&
                                   !is_wordch(es->cbuf[ncursor]) &&
                                   !isspace((unsigned char)es->cbuf[ncursor]))
-                                       ;
+                                       continue;
                        ncursor++;
                }
        }
@@ -1621,18 +1622,18 @@
        ncursor = es->cursor;
        while (ncursor < es->linelen && argcnt--) {
                while (++ncursor < es->linelen - 1 &&
-                               isspace((unsigned char)es->cbuf[ncursor]))
-                       ;
+                   isspace((unsigned char)es->cbuf[ncursor]))
+                       continue;
                if (ncursor < es->linelen - 1) {
                        if (is_wordch(es->cbuf[ncursor]))
                                while (++ncursor < es->linelen &&
-                                         is_wordch(es->cbuf[ncursor]))
-                                       ;
+                                   is_wordch(es->cbuf[ncursor]))
+                                       continue;
                        else
                                while (++ncursor < es->linelen &&
                                   !is_wordch(es->cbuf[ncursor]) &&
                                   !isspace((unsigned char)es->cbuf[ncursor]))
-                                       ;
+                                       continue;
                        ncursor--;
                }
        }
@@ -1647,9 +1648,11 @@
 
        ncursor = es->cursor;
        while (ncursor < es->linelen && argcnt--) {
-               while (!isspace((unsigned char)es->cbuf[ncursor]) && ncursor < es->linelen)
+               while (ncursor < es->linelen &&
+                   !isspace((unsigned char)es->cbuf[ncursor]))
                        ncursor++;
-               while (isspace((unsigned char)es->cbuf[ncursor]) && ncursor < es->linelen)
+               while (ncursor < es->linelen &&
+                   isspace((unsigned char)es->cbuf[ncursor]))
                        ncursor++;
        }
        return ncursor;
@@ -1664,7 +1667,7 @@
        ncursor = es->cursor;
        while (ncursor > 0 && argcnt--) {
                while (--ncursor >= 0 && isspace((unsigned char)es->cbuf[ncursor]))
-                       ;
+                       continue;
                while (ncursor >= 0 && !isspace((unsigned char)es->cbuf[ncursor]))
                        ncursor--;
                ncursor++;
@@ -1681,12 +1684,12 @@
        ncursor = es->cursor;
        while (ncursor < es->linelen - 1 && argcnt--) {
                while (++ncursor < es->linelen - 1 &&
-                               isspace((unsigned char)es->cbuf[ncursor]))
-                       ;
+                   isspace((unsigned char)es->cbuf[ncursor]))
+                       continue;
                if (ncursor < es->linelen - 1) {
                        while (++ncursor < es->linelen &&
-                                       !isspace((unsigned char)es->cbuf[ncursor]))
-                               ;
+                           !isspace((unsigned char)es->cbuf[ncursor]))
+                               continue;
                        ncursor--;
                }
        }



Home | Main Index | Thread Index | Old Index