[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-bluetooth
Subject:    [BlueZ 11/14] isotest: Consider "0" fd to be valid
From:       Bastien Nocera <hadess () hadess ! net>
Date:       2024-05-10 9:11:09
Message-ID: 20240510091814.3172988-12-hadess () hadess ! net
[Download RAW message or body]

Error: RESOURCE_LEAK (CWE-772): [#def79] [important]
bluez-5.75/tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file".
bluez-5.75/tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from \
"open_file(altername)". bluez-5.75/tools/isotest.c:925:3: off_by_one: Testing whether \
handle "fd" is strictly greater than zero is suspicious.  "fd" leaks when it is zero. \
bluez-5.75/tools/isotest.c:925:3: remediation: Did you intend to include equality \
with zero? bluez-5.75/tools/isotest.c:926:4: overwrite_var: Overwriting handle "fd" \
in "fd = open_file(filename)" leaks the handle. 924|
925|		if (fd <= 0)
926|->			fd = open_file(filename);
927|	}
928|
---
 tools/isotest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/isotest.c b/tools/isotest.c
index 7e875fa58b15..810d15d2df2a 100644
--- a/tools/isotest.c
+++ b/tools/isotest.c
@@ -922,7 +922,7 @@ static void send_mode(char *filename, char *peer, int i, bool \
repeat)  if (!err)
 			fd = open_file(altername);
 
-		if (fd <= 0)
+		if (fd < 0)
 			fd = open_file(filename);
 	}
 
-- 
2.44.0


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic