Source-Changes-HG archive

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

[src/trunk]: src/sbin/iscsictl Avoid printing values past the end of the buff...



details:   https://anonhg.NetBSD.org/src/rev/df551755037f
branches:  trunk
changeset: 779809:df551755037f
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jun 20 08:11:11 2012 +0000

description:
Avoid printing values past the end of the buffer, and a size_t underflow.

diffstat:

 sbin/iscsictl/iscsic_driverif.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r b4dd1149d043 -r df551755037f sbin/iscsictl/iscsic_driverif.c
--- a/sbin/iscsictl/iscsic_driverif.c   Wed Jun 20 07:42:27 2012 +0000
+++ b/sbin/iscsictl/iscsic_driverif.c   Wed Jun 20 08:11:11 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsic_driverif.c,v 1.2 2011/10/30 18:40:06 christos Exp $     */
+/*     $NetBSD: iscsic_driverif.c,v 1.3 2012/06/20 08:11:11 martin Exp $       */
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -305,9 +305,13 @@
                }
                printf(" '");
                for (i = 0; i < nelem; i++) {
+                       if (i >= len)
+                               break;
                        printf("%c", isprint(bp[i]) ? bp[i] : ' ');
                }
                printf("'\n");
+               if (len < 16)
+                       break;
                len -= 16;
                bp += 16;
        }



Home | Main Index | Thread Index | Old Index