Skip to content

Commit

Permalink
Merge pull request #8 from quic-mtharu/alert-autofix-4
Browse files Browse the repository at this point in the history
Fix Time-of-check time-of-use filesystem r…
  • Loading branch information
quic-mtharu authored Nov 6, 2024
2 parents f28197c + cd2ef7e commit de3dd00
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fastrpc_cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>

#define FARF_ERROR 1

Expand Down Expand Up @@ -58,11 +59,12 @@ static inline uint32_t fastrpc_check_if_dsp_present_rproc(uint32_t domain) {
while (1) {
memset(buffer, 0, BUF_SIZE);
snprintf(buffer, BUF_SIZE, "%s%d", dir_base_path, dir_index);
if (stat(buffer, &dir_stat) == -1) {
std_strlcat(buffer, "/name", BUF_SIZE);
int fd = open(buffer, O_RDONLY);
if (fd == -1) {
break;
}
std_strlcat(buffer, "/name", BUF_SIZE);
FILE *file = fopen(buffer, "r");
FILE *file = fdopen(fd, "r");
if (file != NULL) {
memset(buffer, 0, BUF_SIZE);
if (fgets(buffer, BUF_SIZE, file) != NULL) {
Expand All @@ -75,6 +77,7 @@ static inline uint32_t fastrpc_check_if_dsp_present_rproc(uint32_t domain) {
}
fclose(file);
}
close(fd);
dir_index++;
}
bail :
Expand Down

0 comments on commit de3dd00

Please sign in to comment.