Module Name: src Committed By: roy Date: Fri Jan 25 12:27:13 UTC 2013
Modified Files: src/usr.bin/tput: tput.c Log Message: If char * > long then print a suitable error when passing a string parameter. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.24 src/usr.bin/tput/tput.c:1.25 --- src/usr.bin/tput/tput.c:1.24 Fri Jan 25 12:12:30 2013 +++ src/usr.bin/tput/tput.c Fri Jan 25 12:27:13 2013 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #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 @@ process(const char *cap, const char *str "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 @@ process(const char *cap, const char *str 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 &&