From: Tedd Ho-Jeong An Date: Mon, 18 Oct 2021 17:28:32 +0000 (-0700) Subject: obexd: Fix unchecked return value X-Git-Tag: submit/tizen/20220313.220938~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7300769ba8aca043982b1c8e2a16f9e76313b18f;p=platform%2Fupstream%2Fbluez.git obexd: Fix unchecked return value This patch fixes the unchecked return value(CWE-252) issues reported by the Coverity. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c index 4ad4582..d8b9f30 100755 --- 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 c622687..3ae4e72 100755 --- 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 12cdcca..3bf4e5c 100755 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -277,7 +277,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] != '/') {