]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* module/dav/main/util.c (dav_check_bufsize): Don't call
authorJoe Orton <jorton@apache.org>
Mon, 17 Feb 2020 17:18:57 +0000 (17:18 +0000)
committerJoe Orton <jorton@apache.org>
Mon, 17 Feb 2020 17:18:57 +0000 (17:18 +0000)
  memcpy(,NULL,0) if the buffer is uninitialized, to avoid tripping
  UBSan.  (Unclear if this is valid for this API.)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874144 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/main/util.c

index f131a486aa92606e3f44d13489a662aeedac40bd..e21f62606806e6587660cd4d22c9d8eddf12929d 100644 (file)
@@ -101,6 +101,9 @@ DAV_DECLARE(dav_error*) dav_join_error(dav_error *dest, dav_error *src)
     return dest;
 }
 
+/* ### Unclear if this was designed to be used with an uninitialized
+ * dav_buffer struct, but is used on by dav_lock_get_activelock().
+ * Hence check for pbuf->buf. */
 DAV_DECLARE(void) dav_check_bufsize(apr_pool_t * p, dav_buffer *pbuf,
                                     apr_size_t extra_needed)
 {
@@ -110,7 +113,8 @@ DAV_DECLARE(void) dav_check_bufsize(apr_pool_t * p, dav_buffer *pbuf,
 
         pbuf->alloc_len += extra_needed + DAV_BUFFER_PAD;
         newbuf = apr_palloc(p, pbuf->alloc_len);
-        memcpy(newbuf, pbuf->buf, pbuf->cur_len);
+        if (pbuf->buf)
+            memcpy(newbuf, pbuf->buf, pbuf->cur_len);
         pbuf->buf = newbuf;
     }
 }