Source-Changes-HG archive

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

[src/trunk]: src/lib/libterminfo Fix an array bounds check - fixes PR lib/42793.



details:   https://anonhg.NetBSD.org/src/rev/6c2c35a9a667
branches:  trunk
changeset: 752058:6c2c35a9a667
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Feb 12 10:36:07 2010 +0000

description:
Fix an array bounds check - fixes PR lib/42793.
Restore a comment (from libterm/tputs.c), requested by jdc.

diffstat:

 lib/libterminfo/tputs.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r f93873b6258c -r 6c2c35a9a667 lib/libterminfo/tputs.c
--- a/lib/libterminfo/tputs.c   Fri Feb 12 10:18:56 2010 +0000
+++ b/lib/libterminfo/tputs.c   Fri Feb 12 10:36:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tputs.c,v 1.1 2010/02/03 15:16:32 roy Exp $ */
+/* $NetBSD: tputs.c,v 1.2 2010/02/12 10:36:07 martin Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tputs.c,v 1.1 2010/02/03 15:16:32 roy Exp $");
+__RCSID("$NetBSD: tputs.c,v 1.2 2010/02/12 10:36:07 martin Exp $");
 
 #include <assert.h>
 #include <ctype.h>
@@ -37,6 +37,11 @@
 #include <term_private.h>
 #include <term.h>
 
+/*
+ * The following array gives the number of tens of milliseconds per
+ * character for each speed as returned by gtty.  Thus since 300
+ * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
+ */
 static const short tmspc10[] = {
        0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5
 };
@@ -78,7 +83,7 @@
 {
        int mspc10;
 
-       if (delay < 1 || os < 1 || (size_t)os >= sizeof(tmspc10))
+       if (delay < 1 || os < 1 || (size_t)os >= __arraycount(tmspc10))
                return;
        
        mspc10 = tmspc10[os];



Home | Main Index | Thread Index | Old Index