summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchin <none@none>2006-06-12 17:10:41 -0700
committerchin <none@none>2006-06-12 17:10:41 -0700
commit70a587dd392ff1dbaa2875c6c33921f08ea85273 (patch)
treef429518c182957284a06d5becd4c94787b66124d
parenta812d87023f09d32794681c7504221439c843e45 (diff)
downloadillumos-joyent-70a587dd392ff1dbaa2875c6c33921f08ea85273.tar.gz
1128254 *csh* csh uses gethostname with MAXHOSTNAME=64 instead of 256
1139642 *csh* csh time does not display fractions of a second 1219707 *csh* csh has a limitation on the size of a substitution string 4499198 *csh* csh accepts bad arguments 6416734 *csh* can't use a variable larger than 19 characters in a foreach statement Contributed by Yann Poupet <opensolaris@yannouch.net>
-rw-r--r--usr/src/cmd/csh/sh.func.c4
-rw-r--r--usr/src/cmd/csh/sh.h5
-rw-r--r--usr/src/cmd/csh/sh.lex.c8
-rw-r--r--usr/src/cmd/csh/sh.proc.c6
-rw-r--r--usr/src/cmd/csh/sh.tchar.c19
-rw-r--r--usr/src/cmd/csh/wait3.c6
6 files changed, 33 insertions, 15 deletions
diff --git a/usr/src/cmd/csh/sh.func.c b/usr/src/cmd/csh/sh.func.c
index 3796f9e4df..79350599df 100644
--- a/usr/src/cmd/csh/sh.func.c
+++ b/usr/src/cmd/csh/sh.func.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -509,7 +509,7 @@ doforeach(tchar **v)
while (*cp && alnum(*cp)) {
cp++;
}
- if (*cp || strlen_(*v) >= 20 || !letter(**v)) {
+ if (*cp || strlen_(*v) >= MAX_VAR_LEN || !letter(**v)) {
bferr("Invalid variable");
}
cp = *v++;
diff --git a/usr/src/cmd/csh/sh.h b/usr/src/cmd/csh/sh.h
index a8f4ec9cb1..6aaf4a716f 100644
--- a/usr/src/cmd/csh/sh.h
+++ b/usr/src/cmd/csh/sh.h
@@ -28,14 +28,11 @@
#include <signal.h> /* std sysV signal.h */
#include <setjmp.h>
#include <sys/resource.h>
+#include <netdb.h> /* for MAXHOSTNAMELEN */
#include "signal.h" /* mainly BSD related signal.h */
#include "sh.local.h"
#include "sh.char.h"
-/*
- * MAXHOSTNAMELEN is defined in param.h under SunOS
- */
-#define MAXHOSTNAMELEN 64
#ifdef MBCHAR
#if !defined(MB_LEN_MAX) || !defined(MB_CUR_MAX)
diff --git a/usr/src/cmd/csh/sh.lex.c b/usr/src/cmd/csh/sh.lex.c
index 3998ad9a51..4286f8669a 100644
--- a/usr/src/cmd/csh/sh.lex.c
+++ b/usr/src/cmd/csh/sh.lex.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -502,9 +502,9 @@ addla(tchar *cp)
lap = labuf;
}
-tchar lhsb[32];
-tchar slhs[32];
-tchar rhsb[64];
+tchar lhsb[256];
+tchar slhs[256];
+tchar rhsb[512];
int quesarg;
void
diff --git a/usr/src/cmd/csh/sh.proc.c b/usr/src/cmd/csh/sh.proc.c
index f9f8459b37..d0d043b3db 100644
--- a/usr/src/cmd/csh/sh.proc.c
+++ b/usr/src/cmd/csh/sh.proc.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -909,6 +909,10 @@ dokill(tchar **v)
return;
}
if (digit(v[0][1])) {
+ if (chkalldigit_(v[0]+1) != 0) {
+ setname(v[0]+1);
+ bferr("Unknown signal; kill -l lists signals");
+ }
signum = atoi_(v[0]+1);
if (signum < 0 || signum > NSIG)
bferr("Bad signal number");
diff --git a/usr/src/cmd/csh/sh.tchar.c b/usr/src/cmd/csh/sh.tchar.c
index 2eef970c8f..acd7856e0e 100644
--- a/usr/src/cmd/csh/sh.tchar.c
+++ b/usr/src/cmd/csh/sh.tchar.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -845,6 +845,23 @@ readlink_(tchar *path, tchar *buf, int bufsiz)
return (i - 1); /* Return # of tchars EXCLUDING the terminating NULL. */
}
+/* checks that it's a number */
+
+int
+chkalldigit_(tchar *str)
+{
+ char chbuf[BUFSIZ * MB_LEN_MAX]; /* General use buffer. */
+ char *c = chbuf;
+
+ (void) tstostr(chbuf, str);
+
+ while (*c)
+ if (!isdigit(*(c++)))
+ return (-1);
+
+ return (0);
+}
+
int
atoi_(tchar *str)
{
diff --git a/usr/src/cmd/csh/wait3.c b/usr/src/cmd/csh/wait3.c
index 75c3ce366e..72b3e863a2 100644
--- a/usr/src/cmd/csh/wait3.c
+++ b/usr/src/cmd/csh/wait3.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -92,9 +92,9 @@ csh_wait3(int *status, int options, struct rusage *rp)
diffu = after_tms.tms_cutime - before_tms.tms_cutime;
diffs = after_tms.tms_cstime - before_tms.tms_cstime;
rp->ru_utime.tv_sec = diffu/HZ;
- rp->ru_utime.tv_usec = (diffu % HZ) / HZ * 1000000;
+ rp->ru_utime.tv_usec = ((diffu % HZ) * 1000000) / HZ;
rp->ru_stime.tv_sec = diffs/HZ;
- rp->ru_stime.tv_usec = (diffs % HZ) / HZ * 1000000;
+ rp->ru_stime.tv_usec = ((diffs % HZ) * 1000000) / HZ;
}
*status = wstat(info.si_code, info.si_status);
return (info.si_pid);