[PATCH] Failed test: scm_rights-fd.test for path containing '>', '}' or non-printable characters

Jay Joshi jay.r.joshi100 at gmail.com
Tue Mar 22 16:22:55 UTC 2016


On Tue, Mar 22, 2016 at 5:29 AM, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Mon, Mar 21, 2016 at 05:18:10PM +0530, Jay Joshi wrote:
>> >From d718d0c8e94cab8a232caf13e282fdea29b9a8eb Mon Sep 17 00:00:00 2001
>> From: JayRJoshi <jay.r.joshi100 at gmail.com>
>> Date: Mon, 21 Mar 2016 17:15:11 +0530
>> Subject: [PATCH] fix pathname containing >,{ and other non-printables
>
> Good catch.
>
>> tests/scm_rights-fd.test: changed regexp for pathname in $rights
>> ---
>>  tests/scm_rights-fd.test | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/scm_rights-fd.test b/tests/scm_rights-fd.test
>> index 48c5028..469348b 100755
>> --- a/tests/scm_rights-fd.test
>> +++ b/tests/scm_rights-fd.test
>> @@ -54,7 +54,7 @@ run_strace -y -x -enetwork $args "$file"
>>  sample='\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff'
>>  n='[1-9][0-9]*'
>>  msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"'"$sample"'", 15\}\],
>> msg_controllen='"$n"
>> -rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
>> cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>,
>> 6</[^}>]*/(A\\n){127}Z>\]\}'
>> +rights='(\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
>> cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>,
>> 6</[^\0]*/(A\\n){127}Z>\]\}|\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
>> cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>,
>> 6<(\\x[0-9a-f][0-9a-f])*\\x2f(\\x41\\x0a){127}\\x5a>\]\})'
>
> You don't have to clone the whole regexp if the only thing that has to be
> changed is the part of regexp related to 6<...>.
>
> BTW, I don't see how your change fixes the issue.
>

First part of "or" was to match for path-name containing printable
characters only. For second part, string_quote while "x" flag set
print whole string in hexadecimal if at least one of the character is
is non-printable. Updated patch is pasted. Am I missing something?

 tests/scm_rights-fd.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/scm_rights-fd.test b/tests/scm_rights-fd.test
index 48c5028..95625b6 100755
--- a/tests/scm_rights-fd.test
+++ b/tests/scm_rights-fd.test
@@ -54,7 +54,7 @@ run_strace -y -x -enetwork $args "$file"
 sample='\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff'
 n='[1-9][0-9]*'
 msg='\{msg_name\(0\)=NULL, msg_iov\(1\)=\[\{"'"$sample"'", 15\}\],
msg_controllen='"$n"
-rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>,
6</[^}>]*/(A\\n){127}Z>\]\}'
+rights='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
cmsg_type=SCM_RIGHTS, \[4</dev/null>, 5</dev/zero>,
6<(/[^\0]*/(A\\n){127}Z|\\x2f(\\x[0-9a-f][0-9a-f])*\\x2f(\\x41\\x0a){127}\\x5a)>\]\}'
 creds='\{cmsg_len='"$n"', cmsg_level=SOL_SOCKET,
cmsg_type=SCM_CREDENTIALS, \{pid='"$n"', uid=[0-9]+, gid=[0-9]+\}\}'
 EXPECTED="$LOG.expected"

-- 
1.9.1




More information about the Strace-devel mailing list