[PATCH v2] test/xattr: don't rely on NUL-termination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <shr@xxxxxx>
Fixes: d6515e06f73c ("liburing: Add new test program to verify xattr support")
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
[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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux