From bc3d72c166c826f6f48c2a8457aaa4e09b6655a0f893967c1620c6ab69a27c8e Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 2 Feb 2012 12:07:46 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=85 --- check-build.sh | 12 +++++----- ksh.changes | 6 +++++ ksh.spec | 5 ++--- ksh93-limit-name-len.dif | 11 ++++++++++ ksh93.dif | 20 +++++++++++++++++ leak1.sh | 26 +++++++++++++++------- leak2.sh | 47 ++++++++++++++++++++++++++++------------ 7 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 ksh93-limit-name-len.dif diff --git a/check-build.sh b/check-build.sh index 50df5c8..f036b3c 100644 --- a/check-build.sh +++ b/check-build.sh @@ -1,11 +1,11 @@ #!/bin/bash -test $(ulimit -l) -lt 64 && exit 1 -test $(ulimit -s) -lt 8192 && exit 1 +test $(ulimit -l) -lt 64 && exit 1 +test $(ulimit -s) -lt 8192 && exit 1 if test $(getconf LONG_BIT) -le 32 ; then - test $(ulimit -m) -lt 6852272 && exit 1 - test $(ulimit -v) -lt 5010688 && exit 1 + test $(ulimit -m) -lt 3145728 && exit 1 + test $(ulimit -v) -lt 4194304 && exit 1 else - test $(ulimit -m) -lt 10471232 && exit 1 - test $(ulimit -v) -lt 6683794 && exit 1 + test $(ulimit -m) -lt 4194304 && exit 1 + test $(ulimit -v) -lt 6683794 && exit 1 fi exit 0 diff --git a/ksh.changes b/ksh.changes index 10963b7..6b994ba 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Feb 2 11:32:15 UTC 2012 - werner@suse.de + +- Fix an off-by-one error which cause that the builtin ulimit may + fail (bnc#744355), patch from Li Bin. + ------------------------------------------------------------------- Tue Jan 24 18:42:48 UTC 2012 - werner@suse.de diff --git a/ksh.spec b/ksh.spec index ba28c84..40bb1ed 100644 --- a/ksh.spec +++ b/ksh.spec @@ -76,6 +76,7 @@ Patch18: ksh93-jobs.dif Patch19: ksh93-reg.dif Patch20: ksh93-aso.dif Patch21: ksh93-vm.dif +Patch22: ksh93-limit-name-len.dif Patch42: ksh-locale.patch %global use_suid_exe 0 %global use_locale 0 @@ -150,6 +151,7 @@ find share/ -type d -a -empty | xargs -r rm -vrf %patch19 %patch20 %patch21 +%patch22 find -type f -a -name Mamfile | \ xargs sed -ri '/exec.*-I-D/{s@(-I)(-D)([^0]*)(0[^[:blank:]]+)@\1\3@}' @@ -319,13 +321,10 @@ find -type f -a -name Mamfile | \ cflags -std=gnu99 RPM_OPT_FLAGS cflags -fPIC RPM_OPT_FLAGS cflags @$nobuiltin RPM_OPT_FLAGS - cflags -fno-unwind-tables RPM_OPT_FLAGS cflags -fno-strict-aliasing RPM_OPT_FLAGS cflags -fno-zero-initialized-in-bss RPM_OPT_FLAGS cflags -fno-delete-null-pointer-checks RPM_OPT_FLAGS - cflags -fno-asynchronous-unwind-tables RPM_OPT_FLAGS cflags -fno-unsafe-loop-optimizations RPM_OPT_FLAGS - cflags -fno-reorder-blocks-and-partition RPM_OPT_FLAGS cflags -fsigned-bitfields RPM_OPT_FLAGS cflags -fsigned-chars RPM_OPT_FLAGS cflags -fsigned-zeros RPM_OPT_FLAGS diff --git a/ksh93-limit-name-len.dif b/ksh93-limit-name-len.dif new file mode 100644 index 0000000..40bf837 --- /dev/null +++ b/ksh93-limit-name-len.dif @@ -0,0 +1,11 @@ +--- src/cmd/ksh93/include/ulimit.h ++++ src/cmd/ksh93/include/ulimit.h 2012-02-02 11:30:00.242435132 +0000 +@@ -157,7 +157,7 @@ + + typedef struct Limit_s + { +- const char name[8]; ++ const char* name; + const char* description; + int index; + const char* conf; diff --git a/ksh93.dif b/ksh93.dif index 3cc00be..4ff9ae5 100644 --- a/ksh93.dif +++ b/ksh93.dif @@ -355,3 +355,23 @@ chmodf = lchmod; goto commit; #else +--- src/cmd/ksh93/sh/xec.c ++++ src/cmd/ksh93/sh/xec.c 2012-01-26 12:07:46.463645375 +0000 +@@ -922,7 +922,7 @@ int sh_exec(register const Shnode_t *t, + { + case TCOM: + { +- register struct argnod *argp; ++ volatile struct argnod *argp; + char *trap; + Namval_t *np, *nq, *last_table; + struct ionod *io; +@@ -1027,7 +1027,7 @@ int sh_exec(register const Shnode_t *t, + comn = com[argn-1]; + } + io = t->tre.treio; +- if(shp->envlist = argp = t->com.comset) ++ if((shp->envlist = argp = t->com.comset)) + { + if(argn==0 || (np && nv_isattr(np,(BLT_DCL|BLT_SPC)))) + { diff --git a/leak1.sh b/leak1.sh index d37a79c..2be93e2 100644 --- a/leak1.sh +++ b/leak1.sh @@ -6,30 +6,40 @@ getSampleInterval() { return 0; } typeset -ilu times=4000 typeset -ilu leak=0 +typeset -a curstate=(0 0 0) +typeset -a oldstate=(0 0 0) + vm() { typeset size typeset key unit result="" while read key size unit; do case "$key" in - VmSize*) result=${result:+"$result:"}$size ;; - VmRSS*) result=${result:+"$result:"}$size ;; - VmData*) result=${result:+"$result:"}$size ;; + VmSize*) result=${result:+"$result "}$size ;; + VmRSS*) result=${result:+"$result "}$size ;; + VmData*) result=${result:+"$result "}$size ;; esac done < /proc/$$/status echo $result } -curstate="XXXX:XXXX:XXXX" -oldstate=$(vm) +lessequal() +{ + typeset -i ret=0 + ((${curstate[0]} > ${oldstate[0]})) && let ret=1 + ((${curstate[1]} > ${oldstate[1]})) && let ret=1 + ((${curstate[2]} > ${oldstate[2]})) && let ret=1 + return $ret +} +oldstate=($(vm)) while ((times-- > 0)) do interval=$(getSampleInterval) - curstate=$(vm) - [ "$curstate" != "$oldstate" ] && let leak++ - oldstate="$curstate" + curstate=($(vm)) + lessequal || let leak++ + oldstate=(${curstate[@]}) done diff --git a/leak2.sh b/leak2.sh index 816ecd7..158a36f 100644 --- a/leak2.sh +++ b/leak2.sh @@ -6,15 +6,18 @@ bla=234 typeset -lui count=4000 typeset -lui leak=0 +typeset -a curstate=(0 0 0) +typeset -a oldstate=(0 0 0) + vm() { typeset size typeset key unit result="" while read key size unit; do case "$key" in - VmSize*) result=${result:+"$result:"}$size ;; - VmRSS*) result=${result:+"$result:"}$size ;; - VmData*) result=${result:+"$result:"}$size ;; + VmSize*) result=${result:+"$result "}$size ;; + VmRSS*) result=${result:+"$result "}$size ;; + VmData*) result=${result:+"$result "}$size ;; esac done < /proc/$$/status echo $result @@ -22,23 +25,39 @@ vm() fusub() { - datun=`date +%S` -# datun=$(date +%S) - interval=$((10 - datun%10)) + datum=`date +%S` + interval=$((10 - datum%10)) } -curstate="XXXX:XXXX:XXXX" -oldstate=$(vm) +fvsub() +{ + datum=$(date +%S) + interval=$((10 - datum%10)) +} +lessequal() +{ + typeset -i ret=0 + ((${curstate[0]} > ${oldstate[0]})) && let ret=1 + ((${curstate[1]} > ${oldstate[1]})) && let ret=1 + ((${curstate[2]} > ${oldstate[2]})) && let ret=1 + return $ret +} + +oldstate=($(vm)) while ((count-- > 0)) do - foo=$((foo+1)) - datum=`fusub` -# datum=$(fusub) + foo=$((foo+1)) - curstate=$(vm) - [ "$curstate" != "$oldstate" ] && let leak++ - oldstate="$curstate" + if ((count%2 == 0)) ; then + datum=`fusub` + else + datum=$(fvsub) + fi + + curstate=($(vm)) + lessequal || let leak++ + oldstate=(${curstate[@]}) done