Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/csh use strtol() for better error handling in builtin ki...
details: https://anonhg.NetBSD.org/src/rev/4536ccb944ee
branches: trunk
changeset: 542828:4536ccb944ee
user: christos <christos%NetBSD.org@localhost>
date: Sat Feb 08 19:40:30 2003 +0000
description:
use strtol() for better error handling in builtin kill (Peter Jeremy)
diffstat:
bin/csh/proc.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diffs (70 lines):
diff -r aa288f09d5e1 -r 4536ccb944ee bin/csh/proc.c
--- a/bin/csh/proc.c Sat Feb 08 19:05:19 2003 +0000
+++ b/bin/csh/proc.c Sat Feb 08 19:40:30 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.c,v 1.25 2003/01/16 09:38:40 kleink Exp $ */
+/* $NetBSD: proc.c,v 1.26 2003/02/08 19:40:30 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: proc.c,v 1.25 2003/01/16 09:38:40 kleink Exp $");
+__RCSID("$NetBSD: proc.c,v 1.26 2003/02/08 19:40:30 christos Exp $");
#endif
#endif /* not lint */
@@ -932,6 +932,7 @@
Char *signame;
char *name;
int signum;
+ char *ep;
signum = SIGTERM;
v++;
@@ -941,7 +942,7 @@
if (!Isdigit(v[1][0]))
stderror(ERR_NAME | ERR_BADSIG);
- signum = atoi(short2str(v[1]));
+ signum = strtol(short2str(v[1]), &ep, 10);
if (signum < 0 || signum >= NSIG)
stderror(ERR_NAME | ERR_BADSIG);
else if (signum == 0)
@@ -959,8 +960,8 @@
return;
}
if (Isdigit(v[0][1])) {
- signum = atoi(short2str(v[0] + 1));
- if (signum < 0 || signum > NSIG)
+ signum = strtol(short2str(v[0] + 1), &ep, 10);
+ if (signum < 0 || signum > NSIG || *ep)
stderror(ERR_NAME | ERR_BADSIG);
}
else {
@@ -1000,6 +1001,7 @@
Char *cp;
sigset_t nsigset;
int err1, jobflags, pid;
+ char *ep;
jobflags = 0;
err1 = 0;
@@ -1056,8 +1058,13 @@
else if (!(Isdigit(*cp) || *cp == '-'))
stderror(ERR_NAME | ERR_JOBARGS);
else {
- pid = atoi(short2str(cp));
- if (kill((pid_t) pid, signum) < 0) {
+ pid = strtoul(short2str(cp), &ep, 0);
+ if (*ep) {
+ (void)fprintf(csherr, "%s: Badly formed number\n",
+ short2str(cp));
+ err1++;
+ goto cont;
+ } else if (kill(pid, signum) < 0) {
(void)fprintf(csherr, "%d: %s\n", pid, strerror(errno));
err1++;
goto cont;
Home |
Main Index |
Thread Index |
Old Index