subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1833601 - in /subversion/trunk: ./ subversion/tests/afl/ subversion/tests/afl/afl-svndiff-testcase/
Date Fri, 15 Jun 2018 14:52:05 GMT
Author: philip
Date: Fri Jun 15 14:52:05 2018
New Revision: 1833601

URL: http://svn.apache.org/viewvc?rev=1833601&view=rev
Log:
Add a fuzzing test for svn_txdelta_parse_svndiff().  No issue found so far.

* build.conf: Add afl-svndiff

* subversion/tests/afl/afl-svndiff.c: New.

* subversion/tests/afl/afl-svndiff-testcase/: New.

* subversion/tests/afl/afl-svndiff-testcase/test1: New.

* subversion/tests/afl/afl-svndiff-testcase/test2: New.

* subversion/tests/afl/afl-svndiff-testcase/test3: New.

Added:
    subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/
    subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test1   (with props)
    subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test2   (with props)
    subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test3   (with props)
    subversion/trunk/subversion/tests/afl/afl-svndiff.c   (with props)
Modified:
    subversion/trunk/build.conf

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1833601&r1=1833600&r2=1833601&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Fri Jun 15 14:52:05 2018
@@ -1588,7 +1588,7 @@ libs = __ALL__
        conflict-data-test db-test pristine-store-test entries-compat-test
        op-depth-test dirent_uri-test wc-queries-test wc-test
        auth-test
-       parse-diff-test x509-test xml-test afl-x509 compress-test
+       parse-diff-test x509-test xml-test afl-x509 afl-svndiff compress-test
        svndiff-stream-test
 
 [__MORE__]
@@ -1749,3 +1749,12 @@ sources = afl-x509.c
 install = test
 libs = libsvn_subr apr
 testing = skip
+
+[afl-svndiff]
+description = AFL fuzzer for svndiff to txdelta parser
+type = exe
+path = subversion/tests/afl
+sources = afl-svndiff.c
+install = test
+libs = libsvn_delta libsvn_subr apr
+testing = skip

Added: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test1
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test1?rev=1833601&view=auto
==============================================================================
Binary file - no diff available.

Propchange: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test1
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test2
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test2?rev=1833601&view=auto
==============================================================================
Binary file - no diff available.

Propchange: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test2
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test3
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test3?rev=1833601&view=auto
==============================================================================
Binary file - no diff available.

Propchange: subversion/trunk/subversion/tests/afl/afl-svndiff-testcase/test3
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: subversion/trunk/subversion/tests/afl/afl-svndiff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/afl/afl-svndiff.c?rev=1833601&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/afl/afl-svndiff.c (added)
+++ subversion/trunk/subversion/tests/afl/afl-svndiff.c Fri Jun 15 14:52:05 2018
@@ -0,0 +1,85 @@
+/*
+ * afl-svndiff.c an American Fuzz Lop test
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ *
+ */
+
+/*  The input data can either be a file on disk or provided via stdin:
+
+       afl-svndiff some-file
+       afl-svndiff < some-file
+
+    In practice the file simply contains random binary data. The data
+    are interpreted as an svndiff as sent by a client to the server. */
+
+#include "svn_delta.h"
+#include "svn_cmdline.h"
+#include "svn_pools.h"
+#include "svn_io.h"
+
+#include <stdlib.h>
+
+static svn_error_t *
+txdelta_window_handler(svn_txdelta_window_t *window,
+                       void *baton)
+{
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+parse(const char *filename, apr_pool_t *pool)
+{
+  svn_stringbuf_t *buf;
+  svn_stream_t *svndiff;
+  svn_stream_t *stream;
+
+  SVN_ERR(svn_stringbuf_from_file2(&buf, filename, pool));
+  svndiff = svn_stream_from_stringbuf(buf, pool);
+
+  stream = svn_txdelta_parse_svndiff(txdelta_window_handler, NULL, TRUE, pool);
+  SVN_ERR(svn_stream_copy3(svndiff, stream, NULL, NULL, pool));
+  
+  return SVN_NO_ERROR;
+}
+
+int main(int argc, char **argv)
+{
+  apr_pool_t *pool;
+  int exit_code = EXIT_SUCCESS;
+  svn_error_t *err;
+  const char *filename;
+
+  if (argc == 2)
+    filename = argv[1];
+  else
+    filename = "-";
+
+  if (svn_cmdline_init("afl-svndiff", stderr) != EXIT_SUCCESS)
+    return EXIT_FAILURE;
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
+
+  err = parse(filename, pool);
+  if (err)
+    exit_code = EXIT_FAILURE;
+  svn_error_clear(err);
+  svn_pool_destroy(pool);
+  return exit_code;
+}

Propchange: subversion/trunk/subversion/tests/afl/afl-svndiff.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message