Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/iscsi avoid buffer overflow



details:   https://anonhg.NetBSD.org/src/rev/0b649d8564f5
branches:  trunk
changeset: 328143:0b649d8564f5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 28 02:15:56 2014 +0000

description:
avoid buffer overflow

diffstat:

 sys/dev/iscsi/iscsi_text.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 27251c74235e -r 0b649d8564f5 sys/dev/iscsi/iscsi_text.c
--- a/sys/dev/iscsi/iscsi_text.c        Thu Mar 27 23:03:06 2014 +0000
+++ b/sys/dev/iscsi/iscsi_text.c        Fri Mar 28 02:15:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_text.c,v 1.6 2012/08/12 13:26:18 mlelstv Exp $   */
+/*     $NetBSD: iscsi_text.c,v 1.7 2014/03/28 02:15:56 christos Exp $  */
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -683,6 +683,8 @@
        }
 
        cc = snprintf(buf, len, "%s=", entries[par->key].name);
+       if (cc >= len)
+               return len;
 
        for (i = 0; i < par->list_num; i++) {
                switch (entries[par->key].val) {
@@ -759,11 +761,17 @@
                DEB(10, ("put_par: value '%s'\n",&buf[cc]));
 
                cc += cl;
+               if (cc >= len)
+                       return len;
                if ((i + 1) < par->list_num) {
+                       if (cc >= len)
+                               return len;
                        buf[cc++] = ',';
                }
        }
 
+       if (cc >= len)
+               return len;
        buf[cc] = 0x0;                          /* make sure it's terminated */
        return cc + 1;                          /* return next place in list */
 }



Home | Main Index | Thread Index | Old Index