]> granicus.if.org Git - strace/commitdiff
xlat: do not strip "1<<" prefix from xlat strings
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 5 May 2016 21:50:23 +0000 (21:50 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 5 May 2016 22:20:40 +0000 (22:20 +0000)
* xlat/gen.sh (cond_xlat, gen_header): Do not strip "1<<" prefix
from xlat strings to fix incorrect output.
* tests/caps.awk: Update.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tests/caps.awk
xlat/gen.sh

index ecf1a28227858b2893fab7f6f11fc26628da723f..67003ac3e7d6a99f99da6927755264daeaea0e23 100644 (file)
@@ -28,7 +28,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 BEGIN {
-       cap = "(0|CAP_[A-Z_]+(\\|CAP_[A-Z_]+)*|CAP_[A-Z_]+(\\|CAP_[A-Z_]+){37}\\|0xffffffc0)"
+       cap = "(0|1<<CAP_[A-Z_]+(\\|1<<CAP_[A-Z_]+)*|1<<CAP_[A-Z_]+(\\|1<<CAP_[A-Z_]+){37}\\|0xffffffc0)"
        s_efault = "-1 EFAULT (Bad address)"
        r_efault = "-1 EFAULT \\(Bad address\\)"
        r_addr = "0x[[:xdigit:]]+"
@@ -36,7 +36,7 @@ BEGIN {
        r[2] = "^capget\\(" r_addr ", " r_addr "\\) = " r_efault
        r[3] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, " r_addr "\\) = " r_efault
        r[4] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$"
-       capset_data = "{CAP_DAC_OVERRIDE|CAP_WAKE_ALARM, CAP_DAC_READ_SEARCH|CAP_BLOCK_SUSPEND, 0}"
+       capset_data = "{1<<CAP_DAC_OVERRIDE|1<<CAP_WAKE_ALARM, 1<<CAP_DAC_READ_SEARCH|1<<CAP_BLOCK_SUSPEND, 0}"
        s[5] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)"
        s[6] = "+++ exited with 0 +++"
 
index 1a0b4d14253f3524aad4dad56261806863273202..bc6982e03559fbc4da27203331ad91f7bec2c449 100755 (executable)
@@ -86,20 +86,19 @@ print_xlat_pair()
 
 cond_xlat()
 {
-       local line val m def xlat str
+       local line val m def xlat
        line="$1"; shift
-       str="$1"; shift
 
        val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
        m="${val%%|*}"
        def="$(printf %s "${line}" |
               sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
 
-       if [ -z "${str}" ]; then
+       if [ "${m}" = "${m#1<<}" ]; then
                xlat="$(print_xlat "${val}")"
        else
+               xlat="$(print_xlat_pair "1ULL<<${val#1<<}" "${val}")"
                m="${m#1<<}"
-               xlat="$(print_xlat_pair "1ULL<<${val#1<<}" "${str}")"
        fi
 
        if [ -z "${def}" ]; then
@@ -204,14 +203,14 @@ gen_header()
                        if [ -n "${unconditional}" ]; then
                                print_xlat "${line}"
                        else
-                               cond_xlat "${line}" ''
+                               cond_xlat "${line}"
                        fi
                        ;;
                '1<<'[A-Z_]*)   # symbolic constants with shift
                        if [ -n "${unconditional}" ]; then
-                               print_xlat_pair "1ULL<<${line#1<<}" "${line#1<<}"
+                               print_xlat_pair "1ULL<<${line#1<<}" "${line}"
                        else
-                               cond_xlat "${line}" "${line#1<<}"
+                               cond_xlat "${line}"
                        fi
                        ;;
                [0-9]*) # numeric constants