Source-Changes-HG archive

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

[src/trunk]: src/lib/libterminfo terminfo: truncate numeric parameters to a s...



details:   https://anonhg.NetBSD.org/src/rev/6d4eb30eedcb
branches:  trunk
changeset: 745786:6d4eb30eedcb
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Mar 12 14:52:04 2020 +0000

description:
terminfo: truncate numeric parameters to a short

Because that is what our API demands.
We should probably change to int when we next bump the API.

diffstat:

 lib/libterminfo/compile.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 7832f73d721e -r 6d4eb30eedcb lib/libterminfo/compile.c
--- a/lib/libterminfo/compile.c Thu Mar 12 14:10:59 2020 +0000
+++ b/lib/libterminfo/compile.c Thu Mar 12 14:52:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.12 2017/05/04 09:46:30 roy Exp $ */
+/* $NetBSD: compile.c,v 1.13 2020/03/12 14:52:04 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: compile.c,v 1.12 2017/05/04 09:46:30 roy Exp $");
+__RCSID("$NetBSD: compile.c,v 1.13 2020/03/12 14:52:04 roy Exp $");
 
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include <sys/endian.h>
@@ -579,7 +579,11 @@
                                    tic->name, token);
                                continue;
                        }
-                       num = (short)cnum;
+
+                       if (cnum > SHRT_MAX)
+                               num = SHRT_MAX;
+                       else
+                               num = (short)cnum;
                        if (ind == -1)
                                _ti_store_extra(tic, 1, token, 'n', -1,
                                    num, NULL, 0, flags);



Home | Main Index | Thread Index | Old Index