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 2021/07/02 10:43:55 UTC
svn commit: r1891196 - in /apr/apr/branches/1.7.x: ./ CHANGES
file_io/unix/readwrite.c locks/unix/proc_mutex.c memory/unix/apr_pools.c
strings/ test/teststr.c
Author: jorton
Date: Fri Jul 2 10:43:55 2021
New Revision: 1891196
URL: http://svn.apache.org/viewvc?rev=1891196&view=rev
Log:
Merge r1878340, r1878343, r1878354, r1878365, r1878342 from trunk:
* memory/unix/apr_pools.c (apr_pvsprintf): Fix a clang warning, the
'active' variable is never read/used before being set again to
pool->active on line 1436.
* file_io/unix/readwrite.c (apr_file_write, apr_file_writev): Fix
Coverity warnings from ignored lseek() return value in ->buffered
handling.
* test/teststr.c: Add trivial testcases for apr_pstrcat (though this
does not reproduce any problems from the bug).
Revert non-test part of r1878354, the Coverity warning was a
false -ve and there was no functional change nor bug.
* locks/unix/proc_mutex.c (apr_proc_mutex_defname): Fix clang warning,
remove unused local variable.
Modified:
apr/apr/branches/1.7.x/ (props changed)
apr/apr/branches/1.7.x/CHANGES
apr/apr/branches/1.7.x/file_io/unix/readwrite.c
apr/apr/branches/1.7.x/locks/unix/proc_mutex.c
apr/apr/branches/1.7.x/memory/unix/apr_pools.c
apr/apr/branches/1.7.x/strings/ (props changed)
apr/apr/branches/1.7.x/test/teststr.c
Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1878340,1878342-1878343,1878354,1878365
Modified: apr/apr/branches/1.7.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?rev=1891196&r1=1891195&r2=1891196&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.7.x/CHANGES [utf-8] Fri Jul 2 10:43:55 2021
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes for APR 1.7.1
+ *) Add error handling for lseek() failures in apr_file_write() and
+ apr_file_writev(). [Joe Orton]
+
*) Align apr_mmap()ing offset to a page boundary. PR 65158. [Yann Ylavic]
*) Don't silently set APR_FOPEN_NOCLEANUP for apr_file_mktemp() created file
Modified: apr/apr/branches/1.7.x/file_io/unix/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/file_io/unix/readwrite.c?rev=1891196&r1=1891195&r2=1891196&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/file_io/unix/readwrite.c (original)
+++ apr/apr/branches/1.7.x/file_io/unix/readwrite.c Fri Jul 2 10:43:55 2021
@@ -146,7 +146,7 @@ APR_DECLARE(apr_status_t) apr_file_read(
APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
{
- apr_size_t rv;
+ apr_size_t rv = APR_SUCCESS;
if (thefile->buffered) {
char *pos = (char *)buf;
@@ -160,13 +160,14 @@ 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) {
if (thefile->bufpos == thefile->bufsize) /* write buffer is full*/
rv = apr_file_flush_locked(thefile);
@@ -244,12 +245,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;
}
if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) {
Modified: apr/apr/branches/1.7.x/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/locks/unix/proc_mutex.c?rev=1891196&r1=1891195&r2=1891196&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/locks/unix/proc_mutex.c (original)
+++ apr/apr/branches/1.7.x/locks/unix/proc_mutex.c Fri Jul 2 10:43:55 2021
@@ -1518,11 +1518,10 @@ static apr_status_t proc_mutex_choose_me
APR_DECLARE(const char *) apr_proc_mutex_defname(void)
{
- apr_status_t rv;
apr_proc_mutex_t mutex;
- if ((rv = proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
- NULL)) != APR_SUCCESS) {
+ if (proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
+ NULL) != APR_SUCCESS) {
return "unknown";
}
Modified: apr/apr/branches/1.7.x/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/memory/unix/apr_pools.c?rev=1891196&r1=1891195&r2=1891196&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/memory/unix/apr_pools.c (original)
+++ apr/apr/branches/1.7.x/memory/unix/apr_pools.c Fri Jul 2 10:43:55 2021
@@ -1338,7 +1338,7 @@ APR_DECLARE(char *) apr_pvsprintf(apr_po
apr_size_t free_index;
pool_concurrency_set_used(pool);
- ps.node = active = pool->active;
+ ps.node = pool->active;
ps.pool = pool;
ps.vbuff.curpos = ps.node->first_avail;
Propchange: apr/apr/branches/1.7.x/strings/
------------------------------------------------------------------------------
Merged /apr/apr/trunk/strings:r1878354,1878365
Modified: apr/apr/branches/1.7.x/test/teststr.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/test/teststr.c?rev=1891196&r1=1891195&r2=1891196&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/test/teststr.c (original)
+++ apr/apr/branches/1.7.x/test/teststr.c Fri Jul 2 10:43:55 2021
@@ -394,6 +394,19 @@ static void skip_prefix(abts_case *tc, v
ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("", "12"), NULL);
}
+static void pstrcat(abts_case *tc, void *data)
+{
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p, "a", "bc", "def", NULL),
+ "abcdef");
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p, NULL), "");
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p,
+ "a", "b", "c", "d", "e",
+ "f", "g", "h", "i", "j",
+ "1", "2", "3", "4", "5",
+ NULL),
+ "abcdefghij12345");
+}
+
abts_suite *teststr(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -412,6 +425,7 @@ abts_suite *teststr(abts_suite *suite)
abts_run_test(suite, string_cpystrn, NULL);
abts_run_test(suite, snprintf_overflow, NULL);
abts_run_test(suite, skip_prefix, NULL);
+ abts_run_test(suite, pstrcat, NULL);
return suite;
}