[BlueZ PATCH 8/9] obexd: Fix unchecked return value

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

 



From: Tedd Ho-Jeong An <tedd.an@xxxxxxxxx>

This patch fixes the unchecked return value(CWE-252) issues reported by
the Coverity.
---
 obexd/client/transfer.c | 12 +++++++++---
 obexd/plugins/pcsuite.c |  4 +++-
 obexd/src/main.c        |  4 +++-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 744d8f106..dccce03b4 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -420,8 +420,11 @@ static void obc_transfer_free(struct obc_transfer *transfer)
 
 	if (transfer->op == G_OBEX_OP_GET &&
 				transfer->status != TRANSFER_STATUS_COMPLETE &&
-				transfer->filename)
-		remove(transfer->filename);
+				transfer->filename) {
+		if (remove(transfer->filename) < 0)
+			error("remove(%s): %s(%d)", transfer->filename,
+							strerror(errno), errno);
+	}
 
 	if (transfer->fd > 0)
 		close(transfer->fd);
@@ -521,7 +524,10 @@ static gboolean transfer_open(struct obc_transfer *transfer, int flags,
 	}
 
 	if (transfer->filename == NULL) {
-		remove(filename); /* remove always only if NULL was given */
+		/* remove always only if NULL was given */
+		if (remove(filename) < 0)
+			error("remove(%s): %s(%d)", filename, strerror(errno),
+									errno);
 		g_free(filename);
 	} else {
 		g_free(transfer->filename);
diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index b2232ea09..f5a9d9ae8 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
@@ -219,7 +219,9 @@ static void pcsuite_disconnect(struct obex_session *os, void *user_data)
 		close(pcsuite->fd);
 
 	if (pcsuite->lock_file) {
-		remove(pcsuite->lock_file);
+		if (remove(pcsuite->lock_file) < 0)
+			error("remove(%s): %s(%d)", pcsuite->lock_file,
+							strerror(errno), errno);
 		g_free(pcsuite->lock_file);
 	}
 
diff --git a/obexd/src/main.c b/obexd/src/main.c
index 04284c9e1..d950883f0 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -270,7 +270,9 @@ int main(int argc, char *argv[])
 	if (option_root == NULL) {
 		option_root = g_build_filename(g_get_user_cache_dir(), "obexd",
 									NULL);
-		g_mkdir_with_parents(option_root, 0700);
+		if (g_mkdir_with_parents(option_root, 0700) < 0)
+			error("Failed to create dir(%d): %s", errno,
+								option_root);
 	}
 
 	if (option_root[0] != '/') {
-- 
2.25.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux