diff mbox series

btrfs-progs: Fix buffer pointer while reading exclusive_operation

Message ID 20201209210955.hcgai4ougmjeiwys@fiona (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: Fix buffer pointer while reading exclusive_operation | expand

Commit Message

Goldwyn Rodrigues Dec. 9, 2020, 9:09 p.m. UTC
While performing the sysfs read for the exclusive_operation, the buffer
pointer is incorrectly subtracted. This reads the file incorrectly and hence
BTRFS_EXCLOP_UNKNOWN is passed everytime the function is called.

Fixes: 1abf37eb btrfs-progs: add helpers for parsing filesystem exclusive operation
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Comments

Nikolay Borisov Dec. 10, 2020, 8:57 a.m. UTC | #1
On 9.12.20 г. 23:09 ч., Goldwyn Rodrigues wrote:
> While performing the sysfs read for the exclusive_operation, the buffer
> pointer is incorrectly subtracted. This reads the file incorrectly and hence
> BTRFS_EXCLOP_UNKNOWN is passed everytime the function is called.
> 
> Fixes: 1abf37eb btrfs-progs: add helpers for parsing filesystem exclusive operation
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> 
> diff --git a/common/utils.c b/common/utils.c
> index 3dc1fdc1..ff29cb81 100644
> --- a/common/utils.c
> +++ b/common/utils.c
> @@ -1952,7 +1952,7 @@ int get_fs_exclop(int fd)
>  		return BTRFS_EXCLOP_UNKNOWN;
>  
>  	memset(buf, 0, sizeof(buf));
> -	ret = sysfs_read_file(sysfs_fd, buf - 1, sizeof(buf));
> +	ret = sysfs_read_file(sysfs_fd, buf, sizeof(buf));
>  	close(sysfs_fd);
>  	if (ret <= 0)
>  		return BTRFS_EXCLOP_UNKNOWN;
>
diff mbox series

Patch

diff --git a/common/utils.c b/common/utils.c
index 3dc1fdc1..ff29cb81 100644
--- a/common/utils.c
+++ b/common/utils.c
@@ -1952,7 +1952,7 @@  int get_fs_exclop(int fd)
 		return BTRFS_EXCLOP_UNKNOWN;
 
 	memset(buf, 0, sizeof(buf));
-	ret = sysfs_read_file(sysfs_fd, buf - 1, sizeof(buf));
+	ret = sysfs_read_file(sysfs_fd, buf, sizeof(buf));
 	close(sysfs_fd);
 	if (ret <= 0)
 		return BTRFS_EXCLOP_UNKNOWN;