Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/tput If char * > long then print a suitable error wh...
details: https://anonhg.NetBSD.org/src/rev/87039993c226
branches: trunk
changeset: 784323:87039993c226
user: roy <roy%NetBSD.org@localhost>
date: Fri Jan 25 12:27:13 2013 +0000
description:
If char * > long then print a suitable error when passing a string parameter.
diffstat:
usr.bin/tput/tput.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (41 lines):
diff -r 7257fcc94cf2 -r 87039993c226 usr.bin/tput/tput.c
--- a/usr.bin/tput/tput.c Fri Jan 25 12:12:30 2013 +0000
+++ b/usr.bin/tput/tput.c Fri Jan 25 12:27:13 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $ */
+/* $NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $ */
/*-
* Copyright (c) 1980, 1988, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95";
#endif
-__RCSID("$NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $");
+__RCSID("$NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $");
#endif /* not lint */
#include <termios.h>
@@ -145,6 +145,8 @@
"Unknown %% escape (%s) for capability `%s'";
static const char errnum[] =
"Expected a numeric argument [%d] (%s) for capability `%s'";
+ static const char errcharlong[] =
+ "Platform does not fit a string into a long for capability '%s'";
int i, nparams, piss[TPARM_MAX];
long nums[TPARM_MAX];
char *strs[TPARM_MAX], *tmp;
@@ -160,9 +162,11 @@
for (i = 0; i < nparams; i++) {
if (*++argv == NULL || *argv[0] == '\0')
errx(2, errfew, nparams, cap);
- if (piss[i])
+ if (piss[i]) {
+ if (sizeof(char *) > sizeof(long) /* CONSTCOND */)
+ errx(2, errcharlong, cap);
strs[i] = *argv;
- else {
+ } else {
errno = 0;
nums[i] = strtol(*argv, &tmp, 0);
if ((errno == ERANGE &&
Home |
Main Index |
Thread Index |
Old Index