FPII-2183: DO NOT MERGE Fix potential DoS caused by delivering signal to BT process

DO NOT MERGE Fix potential DoS caused by delivering signal to BT process

Bug: 28885210
Change-Id: I42fe6830d2f03ea12c4016a11c2eb5cea2903020
diff --git a/osi/src/reactor.c b/osi/src/reactor.c
index e7a3d55..3c6bca1 100644
--- a/osi/src/reactor.c
+++ b/osi/src/reactor.c
@@ -163,7 +163,7 @@
 
     int ret;
     do {
-      ret = select(max_fd + 1, &read_set, &write_set, NULL, tv);
+      ret = TEMP_FAILURE_RETRY(select(max_fd + 1, &read_set, &write_set, NULL, tv));
     } while (ret == -1 && errno == EINTR);
 
     if (ret == -1) {
diff --git a/osi/src/semaphore.c b/osi/src/semaphore.c
index c1d038a..9413569 100644
--- a/osi/src/semaphore.c
+++ b/osi/src/semaphore.c
@@ -67,12 +67,12 @@
   assert(semaphore != NULL);
   assert(semaphore->fd != -1);
 
-  int flags = fcntl(semaphore->fd, F_GETFL);
+  int flags = TEMP_FAILURE_RETRY(fcntl(semaphore->fd, F_GETFL));
   if (flags == -1) {
     ALOGE("%s unable to get flags for semaphore fd: %s", __func__, strerror(errno));
     return false;
   }
-  if (fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK) == -1) {
+  if (TEMP_FAILURE_RETRY(fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK)) == -1) {
     ALOGE("%s unable to set O_NONBLOCK for semaphore fd: %s", __func__, strerror(errno));
     return false;
   }
@@ -81,7 +81,7 @@
   if (eventfd_read(semaphore->fd, &value) == -1)
     return false;
 
-  if (fcntl(semaphore->fd, F_SETFL, flags) == -1)
+  if (TEMP_FAILURE_RETRY(fcntl(semaphore->fd, F_SETFL, flags)) == -1)
     ALOGE("%s unable to resetore flags for semaphore fd: %s", __func__, strerror(errno));
   return true;
 }