summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authormj162486 <none@none>2006-05-19 01:11:12 -0700
committermj162486 <none@none>2006-05-19 01:11:12 -0700
commit0b46ffbad80838700776674f5dea3ad9b16dd6e4 (patch)
treeecbbb5ebe753d6125a2f25485c313725558707c8 /usr
parent440e4ad19f859ba6e6bc6e5003e8d32a54a7a501 (diff)
downloadillumos-gate-0b46ffbad80838700776674f5dea3ad9b16dd6e4.tar.gz
6388209 Bourne shell's own internal malloc() causes SEGV for some 64bit library routines
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/sh/blok.c16
-rw-r--r--usr/src/cmd/sh/mode.h30
2 files changed, 28 insertions, 18 deletions
diff --git a/usr/src/cmd/sh/blok.c b/usr/src/cmd/sh/blok.c
index e2133e7b39..17352dc773 100644
--- a/usr/src/cmd/sh/blok.c
+++ b/usr/src/cmd/sh/blok.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
*/
/*
- * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -61,7 +60,7 @@ char *
alloc(nbytes)
size_t nbytes;
{
- unsigned rbytes = round(nbytes+BYTESPERWORD, BYTESPERWORD);
+ unsigned rbytes = round(nbytes + ALIGNSIZ, ALIGNSIZ);
if (stakbot == 0) {
addblok((unsigned)0);
@@ -102,6 +101,11 @@ addblok(unsigned int reqd)
{
if (stakbot == 0) {
brkbegin = setbrk(3 * BRKINCR);
+ /*
+ * setbrk() returns 8 byte aligned address
+ * but we could need larger align in future
+ */
+ brkbegin = (unsigned char *)round(brkbegin, ALIGNSIZ);
bloktop = (struct blk *)brkbegin;
}
@@ -112,7 +116,7 @@ addblok(unsigned int reqd)
if (staktop >= brkend)
growstak(staktop);
pushstak(0);
- rndstak = (unsigned char *)round(staktop, BYTESPERWORD);
+ rndstak = (unsigned char *)round(staktop, ALIGNSIZ);
blokstak = (struct blk *)(stakbas) - 1;
blokstak->word = stakbsy;
stakbsy = blokstak;
diff --git a/usr/src/cmd/sh/mode.h b/usr/src/cmd/sh/mode.h
index 43ad7db9a6..8235f7f930 100644
--- a/usr/src/cmd/sh/mode.h
+++ b/usr/src/cmd/sh/mode.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,16 +18,18 @@
*
* CDDL HEADER END
*/
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
-
/*
- * Copyright (c) 1996, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifndef _MODE_H
+#define _MODE_H
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8.1.2 */
/*
* UNIX shell
*/
@@ -42,10 +43,12 @@ typedef short BOOL;
#endif
#define BYTESPERWORD (sizeof (char *))
-#define NIL ((char*)0)
+#define ALIGNSIZ (sizeof (double))
+#define NIL ((char *)0)
-/* the following nonsense is required
+/*
+ * the following nonsense is required
* because casts turn an Lvalue
* into an Rvalue so two cheats
* are necessary, one for each context.
@@ -74,6 +77,7 @@ typedef union
struct blk
{
struct blk *word;
+ char pad[ALIGNSIZ - sizeof (struct blk *)];
};
/*
@@ -251,3 +255,5 @@ struct fdsave
#define whptr(x) ((struct whnod *)x)
#define ifptr(x) ((struct ifnod *)x)
#define swptr(x) ((struct swnod *)x)
+
+#endif /* _MODE_H */