slackbuilds_ponce/system/pdksh/patches/113_OpenBSD-memory.patch
2010-05-13 01:01:03 +02:00

148 lines
4 KiB
Diff

From OpenBSD:
2009-04-19 22:34 sthen
* misc.c (1.37): don't print extraneous padding characters when
tab-completion file/command lists encounter a name too long for
the width of the terminal.
from Matthew Haub, no objections krw@.
2008-08-11 23:50 jaredy
* tree.c (1.19): plug a memleak when freeing io redirection in
commands. the leaked memory is actually reclaimed when the
command finishes but may grow until that happens, e.g. during
command execution.
ok phessler@. testing sobrado@ jmc@ oga@.
2008-07-23 18:34 jaredy
* c_sh.c (1.38), syn.c (1.28): fix stack abuse in the `time'
commmand, using alloc()'d memory instead.
reported by Thorsten Glaser, thanks.
ok millert@, earlier version miod@
2008-07-21 19:30 millert
* alloc.c (1.8): Extra sanity checking for afree(); OK deraadt@
and pvalchev@
2008-07-12 14:33 miod
* misc.c (1.34): Fix a strlcpy() bound.
Index: pdksh-5.2.14/tree.c
===================================================================
--- pdksh-5.2.14.orig/tree.c 2009-09-19 11:22:37.000000000 +0200
+++ pdksh-5.2.14/tree.c 2009-09-19 12:06:43.000000000 +0200
@@ -755,4 +755,5 @@
afree((void*)p->heredoc, ap);
afree((void*)p, ap);
}
+ afree(iow, ap);
}
Index: pdksh-5.2.14/syn.c
===================================================================
--- pdksh-5.2.14.orig/syn.c 2009-09-19 11:22:37.000000000 +0200
+++ pdksh-5.2.14/syn.c 2009-09-19 12:06:43.000000000 +0200
@@ -375,6 +375,11 @@
case TIME:
syniocf &= ~(KEYWORD|ALIAS);
t = pipeline(0);
+ if (t) {
+ t->str = alloc(2, ATEMP);
+ t->str[0] = '\0'; /* TF_* flags */
+ t->str[1] = '\0';
+ }
t = block(TTIME, t, NOBLOCK, NOWORDS);
break;
Index: pdksh-5.2.14/alloc.c
===================================================================
--- pdksh-5.2.14.orig/alloc.c 2009-09-19 11:22:37.000000000 +0200
+++ pdksh-5.2.14/alloc.c 2009-09-19 12:06:43.000000000 +0200
@@ -894,13 +894,20 @@
void
afree(void *ptr, Area *ap)
{
- struct link *l;
+ struct link *l, *l2;
if (!ptr)
return;
l = P2L(ptr);
+ for (l2 = ap->freelist; l2 != NULL; l2 = l2->next) {
+ if (l == l2)
+ break;
+ }
+ if (l2 == NULL)
+ internal_errorf(1, "afree: %p not present in area %p", ptr, ap);
+
if (l->prev)
l->prev->next = l->next;
else
Index: pdksh-5.2.14/c_sh.c
===================================================================
--- pdksh-5.2.14.orig/c_sh.c 2009-09-19 11:55:01.000000000 +0200
+++ pdksh-5.2.14/c_sh.c 2009-09-19 12:06:43.000000000 +0200
@@ -738,7 +738,6 @@
clock_t t0t, t1t = 0;
int tf = 0;
extern clock_t j_usrtime, j_systime; /* computed by j_wait */
- char opts[1];
t0t = ksh_times(&t0);
if (t->left) {
@@ -751,11 +750,9 @@
* really work as it only counts the last job).
*/
j_usrtime = j_systime = 0;
- if (t->left->type == TCOM)
- t->left->str = opts;
- opts[0] = 0;
rv = execute(t->left, f | XTIME, xerrok);
- tf |= opts[0];
+ if (t->left->type == TCOM)
+ tf |= t->left->str[0];
t1t = ksh_times(&t1);
} else
tf = TF_NOARGS;
Index: pdksh-5.2.14/misc.c
===================================================================
--- pdksh-5.2.14.orig/misc.c 2009-09-19 11:22:37.000000000 +0200
+++ pdksh-5.2.14/misc.c 2009-09-19 12:06:43.000000000 +0200
@@ -1123,6 +1123,7 @@
int r, c;
int rows, cols;
int nspace;
+ int col_width;
/* max_width + 1 for the space. Note that no space
* is printed after the last column to avoid problems
@@ -1141,6 +1142,9 @@
rows = n;
}
+ col_width = max_width;
+ if (cols == 1)
+ col_width = 0; /* Don't pad entries in single column output. */
nspace = (x_cols - max_width * cols) / cols;
if (nspace <= 0)
nspace = 1;
@@ -1149,7 +1153,7 @@
i = c * rows + r;
if (i < n) {
shf_fprintf(shf, "%-*s",
- max_width,
+ col_width,
(*func)(arg, i, str, max_width + 1));
if (c + 1 < cols)
shf_fprintf(shf, "%*s", nspace, null);