gatt: add return value check of io_get_fd() to sock_io_send()
It is necessary to add a return value check.
Found with the SVACE static analysis tool.
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 8472aac..6c84b08 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2630,6 +2630,7 @@
{
struct msghdr msg;
struct iovec iov;
+ int fd;
iov.iov_base = (void *) data;
iov.iov_len = len;
@@ -2638,7 +2639,13 @@
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- return sendmsg(io_get_fd(io), &msg, MSG_NOSIGNAL);
+ fd = io_get_fd(io);
+ if (fd < 0) {
+ error("io_get_fd() returned %d\n", fd);
+ return fd;
+ }
+
+ return sendmsg(fd, &msg, MSG_NOSIGNAL);
}
static void att_disconnect_cb(int err, void *user_data)