Skip to content

Commit

Permalink
Add coverity-only check for underflow (CID #1604625)
Browse files Browse the repository at this point in the history
Check accumulation of total to pacify Coverity in fr_writev()
  • Loading branch information
jejones3141 committed Jul 29, 2024
1 parent c092c52 commit b804c86
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/util/iovec.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ ssize_t fr_writev(int fd, struct iovec vector[], int iovcnt, fr_time_delta_t tim

wrote = writev(fd, vector_p, iovcnt);
if (wrote > 0) {
#ifdef __COVERITY__
/*
* Coverity thinks that total += wrote might underflow,
* which causes an issue at the return.
*/
if (total + wrote < total) return -1;
#endif
total += wrote;
while (wrote > 0) {
/*
Expand Down

0 comments on commit b804c86

Please sign in to comment.