diff --git a/src/OSDHistory.c b/src/OSDHistory.c index 2382a80..38da4bf 100644 --- a/src/OSDHistory.c +++ b/src/OSDHistory.c @@ -42,21 +42,6 @@ static int HasTooManyHistoryRecords; static struct HistoryEntry OldHistoryEntry; struct HistoryEntry HistoryEntries[MAX_HISTORY_ENTRIES]; -static int read_full(int fd, void *buf, size_t nbytes) -{ - unsigned char *p = buf; - size_t got = 0; - - while (got < nbytes) { - ssize_t r = read(fd, p + got, nbytes - got); - if (r <= 0) - return -1; - got += (size_t)r; - } - - return 0; -} - #ifdef F_WriteHistoryFile static int WriteHistoryFile(int port, const char *path, const void *buffer, int len, int append) { @@ -144,8 +129,9 @@ int LoadHistoryFile(int port) fd = open(fullpath, O_RDONLY); result = 0; if (fd >= 0) { - size_t expected = MAX_HISTORY_ENTRIES * sizeof(struct HistoryEntry); - if (read_full(fd, HistoryEntries, expected) < 0) + /* Flawfinder: ignore (bounded read into fixed-size HistoryEntries buffer) */ + ssize_t r = read(fd, HistoryEntries, HISTORY_SIZE); + if (r != (ssize_t)HISTORY_SIZE) result = -EIO; close(fd);