public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jiri Slaby <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], Jiri Slaby <[email protected]>,
	Stefan Roesch <[email protected]>
Subject: [PATCH v2] test/xattr: don't rely on NUL-termination
Date: Tue, 16 Aug 2022 12:51:34 +0200	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

The returned value from io_uring_fgetxattr() needs not be NUL-terminated,
as we stored non-NUL-terminated string by io_uring_fsetxattr()
previously.

So don't use strlen() on value, but on VALUE1, and VALUE2 respectively.

This fixes random test failures.

Cc: Stefan Roesch <[email protected]>
Fixes: d6515e06f73c ("liburing: Add new test program to verify xattr support")
Signed-off-by: Jiri Slaby <[email protected]>
---
[v2] added Fixes, Cc, and fixed a typo in the message above.

 test/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/xattr.c b/test/xattr.c
index d88059cb..101d82b3 100644
--- a/test/xattr.c
+++ b/test/xattr.c
@@ -210,14 +210,14 @@ static int test_fxattr(void)
 
 	/* Test reading attributes. */
 	value_len = io_uring_fgetxattr(&ring, fd, KEY1, value, XATTR_SIZE);
-	if (value_len != strlen(value) || strncmp(value, VALUE1, value_len)) {
+	if (value_len != strlen(VALUE1) || strncmp(value, VALUE1, value_len)) {
 		fprintf(stderr, "Error: fgetxattr expected value: %s, returned value: %s\n", VALUE1, value);
 		rc = -1;
 		goto Exit;
 	}
 
 	value_len = io_uring_fgetxattr(&ring, fd, KEY2, value, XATTR_SIZE);
-	if (value_len != strlen(value)|| strncmp(value, VALUE2, value_len)) {
+	if (value_len != strlen(VALUE2) || strncmp(value, VALUE2, value_len)) {
 		fprintf(stderr, "Error: fgetxattr expected value: %s, returned value: %s\n", VALUE2, value);
 		rc = -1;
 		goto Exit;
-- 
2.35.3


       reply	other threads:[~2022-08-16 11:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <[email protected]>
2022-08-16 10:51 ` Jiri Slaby [this message]
2022-08-16 12:23   ` [PATCH v2] test/xattr: don't rely on NUL-termination Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox