You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2020/06/01 09:15:21 UTC
svn commit: r1878343 - /apr/apr/trunk/file_io/unix/readwrite.c
Author: jorton
Date: Mon Jun 1 09:15:20 2020
New Revision: 1878343
URL: http://svn.apache.org/viewvc?rev=1878343&view=rev
Log:
* file_io/unix/readwrite.c (apr_file_write, apr_file_writev): Fix
Coverity warnings from ignored lseek() return value in ->buffered
handling.
Modified:
apr/apr/trunk/file_io/unix/readwrite.c
Modified: apr/apr/trunk/file_io/unix/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/readwrite.c?rev=1878343&r1=1878342&r2=1878343&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/readwrite.c (original)
+++ apr/apr/trunk/file_io/unix/readwrite.c Mon Jun 1 09:15:20 2020
@@ -244,14 +244,15 @@ APR_DECLARE(apr_status_t) apr_file_write
* logically reading from
*/
apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
- if (offset != thefile->filePtr)
- lseek(thefile->filedes, offset, SEEK_SET);
+ if (offset != thefile->filePtr) {
+ thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
+ if (thefile->filePtr == -1) rv = errno;
+ }
thefile->bufpos = thefile->dataRead = 0;
thefile->direction = 1;
}
- rv = 0;
- while (rv == 0 && size > 0) {
+ while (rv == APR_SUCCESS && size > 0) {
if (thefile->bufpos == thefile->bufsize) /* write buffer is full*/
rv = apr_file_flush_locked(thefile);
@@ -328,12 +329,15 @@ APR_DECLARE(apr_status_t) apr_file_write
*/
apr_int64_t offset = thefile->filePtr - thefile->dataRead +
thefile->bufpos;
- if (offset != thefile->filePtr)
- lseek(thefile->filedes, offset, SEEK_SET);
+ if (offset != thefile->filePtr) {
+ thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
+ if (thefile->filePtr == -1) rv = errno;
+ }
thefile->bufpos = thefile->dataRead = 0;
}
file_unlock(thefile);
+ if (rv) return rv;
}
rv = file_rotating_check(thefile);