Skip to contentSkip to conversation

xfs_io: fix signed comparison problem in copy_file_range

PATCH In review Darrick J. Wong 2 participants 2 messages Jun 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: fix signed comparison problem in copy_file_range

From: Darrick J. Wong <[email protected]>

cvtnum() returns a signed long long, so the type of 'len' should be a signed type so that a user entering a negative length doesn't produce some huge positive integer. The negative len check demands it anyway.

Coverity-id: 1435895

Fixes 25b4549c8b54134106cff094aa098eab9e86eee7
---
 io/copy_file_range.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io/copy_file_range.c +1 -1
index ebd1ec76..4d0770ef 100644
@@ -91,7 +91,7 @@ copy_range_f(int argc, char **argv)
 {
 	long long src = 0;
 	long long dst = 0;
-	size_t len = 0;
+	long long len = 0;
 	int opt;
 	int ret;
 	int fd;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

cvtnum() returns a signed long long, so the type of 'len' should be a signed type so that a user entering a negative length doesn't produce some huge positive integer. The negative len check demands it anyway.

Coverity-id: 1435895

Fixes 25b4549c8b54134106cff094aa098eab9e86eee7

*sigh* I actually looked at the first two long longs, verified that's what cvtnum returned, and moved on before spot-checking the 3rd o_O.

Thanks!

Quoted 17 lines
---
 io/copy_file_range.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io/copy_file_range.c +1 -1
index ebd1ec76..4d0770ef 100644
@@ -91,7 +91,7 @@ copy_range_f(int argc, char **argv)
 {
 	long long src = 0;
 	long long dst = 0;
-	size_t len = 0;
+	long long len = 0;
 	int opt;
 	int ret;
 	int fd;