subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1632530 - in /subversion/trunk/subversion: include/svn_string.h libsvn_subr/string.c
Date Fri, 17 Oct 2014 10:34:30 GMT
Author: philip
Date: Fri Oct 17 10:34:30 2014
New Revision: 1632530

URL: http://svn.apache.org/r1632530
Log:
Make svn_stringbuf_appendbytes(..., NULL, 0) be well defined by
avoiding passing NULL to memcpy. GCC's undefined behaviour sanitizer
detects that we do this during skel unparsing.

* subversion/include/svn_string.h
  (svn_stringbuf_appendbytes): Document behaviour.

* subversion/libsvn_subr/string.c
  (svn_stringbuf_appendbytes): Return early.

Modified:
    subversion/trunk/subversion/include/svn_string.h
    subversion/trunk/subversion/libsvn_subr/string.c

Modified: subversion/trunk/subversion/include/svn_string.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_string.h?rev=1632530&r1=1632529&r2=1632530&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_string.h (original)
+++ subversion/trunk/subversion/include/svn_string.h Fri Oct 17 10:34:30 2014
@@ -307,6 +307,8 @@ svn_stringbuf_appendbyte(svn_stringbuf_t
 /** Append an array of bytes onto @a targetstr.
  *
  * reallocs if necessary. @a targetstr is affected, nothing else is.
+ *
+ * @since 1.9 @a bytes can be NULL if @a count is zero.
  */
 void
 svn_stringbuf_appendbytes(svn_stringbuf_t *targetstr,

Modified: subversion/trunk/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/string.c?rev=1632530&r1=1632529&r2=1632530&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/string.c (original)
+++ subversion/trunk/subversion/libsvn_subr/string.c Fri Oct 17 10:34:30 2014
@@ -589,6 +589,10 @@ svn_stringbuf_appendbytes(svn_stringbuf_
   apr_size_t total_len;
   void *start_address;
 
+  if (!count)
+    /* Allow BYTES to be NULL by avoiding passing it to memcpy. */
+    return;
+
   total_len = str->len + count;  /* total size needed */
 
   /* svn_stringbuf_ensure adds 1 for null terminator. */



Mime
View raw message