Blame SOURCES/apr-1.7.0-r1891269+.patch

d657f6
# ./pullrev.sh 1891269 1891198 1891196
d657f6
http://svn.apache.org/viewvc?view=revision&revision=1891269
d657f6
http://svn.apache.org/viewvc?view=revision&revision=1891198
d657f6
http://svn.apache.org/viewvc?view=revision&revision=1891196
d657f6
d657f6
--- apr-1.7.0/include/arch/unix/apr_arch_thread_mutex.h
d657f6
+++ apr-1.7.0/include/arch/unix/apr_arch_thread_mutex.h
d657f6
@@ -33,8 +33,10 @@
d657f6
 struct apr_thread_mutex_t {
d657f6
     apr_pool_t *pool;
d657f6
     pthread_mutex_t mutex;
d657f6
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
d657f6
     apr_thread_cond_t *cond;
d657f6
     int locked, num_waiters;
d657f6
+#endif
d657f6
 };
d657f6
 #endif
d657f6
 
d657f6
--- apr-1.7.0/locks/unix/thread_mutex.c
d657f6
+++ apr-1.7.0/locks/unix/thread_mutex.c
d657f6
@@ -102,6 +102,7 @@
d657f6
 {
d657f6
     apr_status_t rv;
d657f6
 
d657f6
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
d657f6
     if (mutex->cond) {
d657f6
         apr_status_t rv2;
d657f6
 
d657f6
@@ -133,6 +134,7 @@
d657f6
 
d657f6
         return rv;
d657f6
     }
d657f6
+#endif
d657f6
 
d657f6
     rv = pthread_mutex_lock(&mutex->mutex);
d657f6
 #ifdef HAVE_ZOS_PTHREADS
d657f6
@@ -148,6 +150,7 @@
d657f6
 {
d657f6
     apr_status_t rv;
d657f6
 
d657f6
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
d657f6
     if (mutex->cond) {
d657f6
         apr_status_t rv2;
d657f6
 
d657f6
@@ -177,6 +180,7 @@
d657f6
 
d657f6
         return rv;
d657f6
     }
d657f6
+#endif
d657f6
 
d657f6
     rv = pthread_mutex_trylock(&mutex->mutex);
d657f6
     if (rv) {
d657f6
@@ -281,6 +285,7 @@
d657f6
 {
d657f6
     apr_status_t status;
d657f6
 
d657f6
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
d657f6
     if (mutex->cond) {
d657f6
         status = pthread_mutex_lock(&mutex->mutex);
d657f6
         if (status) {
d657f6
@@ -303,6 +308,7 @@
d657f6
 
d657f6
         mutex->locked = 0;
d657f6
     }
d657f6
+#endif
d657f6
 
d657f6
     status = pthread_mutex_unlock(&mutex->mutex);
d657f6
 #ifdef HAVE_ZOS_PTHREADS
d657f6
@@ -318,9 +324,12 @@
d657f6
 {
d657f6
     apr_status_t rv, rv2 = APR_SUCCESS;
d657f6
 
d657f6
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
d657f6
     if (mutex->cond) {
d657f6
         rv2 = apr_thread_cond_destroy(mutex->cond);
d657f6
     }
d657f6
+#endif
d657f6
+
d657f6
     rv = apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup);
d657f6
     if (rv == APR_SUCCESS) {
d657f6
         rv = rv2;
d657f6
--- apr-1.7.0/random/unix/sha2.c
d657f6
+++ apr-1.7.0/random/unix/sha2.c
d657f6
@@ -425,7 +425,7 @@
d657f6
         usedspace = freespace = 0;
d657f6
 }
d657f6
 
d657f6
-void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
d657f6
+void apr__SHA256_Final(sha2_byte digest[SHA256_DIGEST_LENGTH], SHA256_CTX* context) {
d657f6
         sha2_word32     *d = (sha2_word32*)digest;
d657f6
         unsigned int    usedspace;
d657f6
 
d657f6
@@ -496,7 +496,7 @@
d657f6
         usedspace = 0;
d657f6
 }
d657f6
 
d657f6
-char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) {
d657f6
+char *apr__SHA256_End(SHA256_CTX* context, char buffer[SHA256_DIGEST_STRING_LENGTH]) {
d657f6
         sha2_byte       digest[SHA256_DIGEST_LENGTH], *d = digest;
d657f6
         int             i;
d657f6
 
d657f6
--- apr-1.7.0/time/unix/time.c
d657f6
+++ apr-1.7.0/time/unix/time.c
d657f6
@@ -142,6 +142,9 @@
d657f6
     static const int dayoffset[12] =
d657f6
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
d657f6
 
d657f6
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
d657f6
+        return APR_EBADDATE;
d657f6
+
d657f6
     /* shift new year to 1st March in order to make leap year calc easy */
d657f6
 
d657f6
     if (xt->tm_mon < 2)
d657f6
--- apr-1.7.0/time/win32/time.c
d657f6
+++ apr-1.7.0/time/win32/time.c
d657f6
@@ -54,6 +54,9 @@
d657f6
     static const int dayoffset[12] =
d657f6
     {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
d657f6
 
d657f6
+    if (tm->wMonth < 1 || tm->wMonth > 12)
d657f6
+        return APR_EBADDATE;
d657f6
+
d657f6
     /* Note; the caller is responsible for filling in detailed tm_usec,
d657f6
      * tm_gmtoff and tm_isdst data when applicable.
d657f6
      */
d657f6
@@ -228,6 +231,9 @@
d657f6
     static const int dayoffset[12] =
d657f6
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
d657f6
 
d657f6
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
d657f6
+        return APR_EBADDATE;
d657f6
+
d657f6
     /* shift new year to 1st March in order to make leap year calc easy */
d657f6
 
d657f6
     if (xt->tm_mon < 2)
d657f6
--- apr-1.7.0/file_io/unix/readwrite.c
d657f6
+++ apr-1.7.0/file_io/unix/readwrite.c
d657f6
@@ -146,7 +146,7 @@
d657f6
 
d657f6
 APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
d657f6
 {
d657f6
-    apr_size_t rv;
d657f6
+    apr_size_t rv = APR_SUCCESS;
d657f6
 
d657f6
     if (thefile->buffered) {
d657f6
         char *pos = (char *)buf;
d657f6
@@ -160,13 +160,14 @@
d657f6
              * logically reading from
d657f6
              */
d657f6
             apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
d657f6
-            if (offset != thefile->filePtr)
d657f6
-                lseek(thefile->filedes, offset, SEEK_SET);
d657f6
+            if (offset != thefile->filePtr) {
d657f6
+                thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
d657f6
+                if (thefile->filePtr == -1) rv = errno;
d657f6
+            }
d657f6
             thefile->bufpos = thefile->dataRead = 0;
d657f6
             thefile->direction = 1;
d657f6
         }
d657f6
 
d657f6
-        rv = 0;
d657f6
         while (rv == 0 && size > 0) {
d657f6
             if (thefile->bufpos == thefile->bufsize)   /* write buffer is full*/
d657f6
                 rv = apr_file_flush_locked(thefile);
d657f6
@@ -244,12 +245,15 @@
d657f6
              */
d657f6
             apr_int64_t offset = thefile->filePtr - thefile->dataRead +
d657f6
                                  thefile->bufpos;
d657f6
-            if (offset != thefile->filePtr)
d657f6
-                lseek(thefile->filedes, offset, SEEK_SET);
d657f6
+            if (offset != thefile->filePtr) {
d657f6
+                thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
d657f6
+                if (thefile->filePtr == -1) rv = errno;
d657f6
+            }
d657f6
             thefile->bufpos = thefile->dataRead = 0;
d657f6
         }
d657f6
 
d657f6
         file_unlock(thefile);
d657f6
+        if (rv) return rv;
d657f6
     }
d657f6
 
d657f6
     if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) {
d657f6
--- apr-1.7.0/locks/unix/proc_mutex.c
d657f6
+++ apr-1.7.0/locks/unix/proc_mutex.c
d657f6
@@ -1518,11 +1518,10 @@
d657f6
 
d657f6
 APR_DECLARE(const char *) apr_proc_mutex_defname(void)
d657f6
 {
d657f6
-    apr_status_t rv;
d657f6
     apr_proc_mutex_t mutex;
d657f6
 
d657f6
-    if ((rv = proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
d657f6
-                                       NULL)) != APR_SUCCESS) {
d657f6
+    if (proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
d657f6
+                                 NULL) != APR_SUCCESS) {
d657f6
         return "unknown";
d657f6
     }
d657f6
 
d657f6
--- apr-1.7.0/memory/unix/apr_pools.c
d657f6
+++ apr-1.7.0/memory/unix/apr_pools.c
d657f6
@@ -1338,7 +1338,7 @@
d657f6
     apr_size_t free_index;
d657f6
 
d657f6
     pool_concurrency_set_used(pool);
d657f6
-    ps.node = active = pool->active;
d657f6
+    ps.node = pool->active;
d657f6
     ps.pool = pool;
d657f6
     ps.vbuff.curpos  = ps.node->first_avail;
d657f6
 
d657f6
--- apr-1.7.0/test/teststr.c
d657f6
+++ apr-1.7.0/test/teststr.c
d657f6
@@ -394,6 +394,19 @@
d657f6
     ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("",      "12"),    NULL);
d657f6
 }
d657f6
 
d657f6
+static void pstrcat(abts_case *tc, void *data)
d657f6
+{
d657f6
+    ABTS_STR_EQUAL(tc, apr_pstrcat(p, "a", "bc", "def", NULL),
d657f6
+                   "abcdef");
d657f6
+    ABTS_STR_EQUAL(tc, apr_pstrcat(p, NULL), "");
d657f6
+    ABTS_STR_EQUAL(tc, apr_pstrcat(p,
d657f6
+                                   "a", "b", "c", "d", "e",
d657f6
+                                   "f", "g", "h", "i", "j",
d657f6
+                                   "1", "2", "3", "4", "5",
d657f6
+                                   NULL),
d657f6
+                   "abcdefghij12345");
d657f6
+}
d657f6
+
d657f6
 abts_suite *teststr(abts_suite *suite)
d657f6
 {
d657f6
     suite = ADD_SUITE(suite)
d657f6
@@ -412,6 +425,7 @@
d657f6
     abts_run_test(suite, string_cpystrn, NULL);
d657f6
     abts_run_test(suite, snprintf_overflow, NULL);
d657f6
     abts_run_test(suite, skip_prefix, NULL);
d657f6
+    abts_run_test(suite, pstrcat, NULL);
d657f6
 
d657f6
     return suite;
d657f6
 }