~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2013-1968.patch

  • Committer: Package Import Robot
  • Author(s): Salvatore Bonaccorso
  • Date: 2013-06-06 13:14:52 UTC
  • Revision ID: package-import@ubuntu.com-20130606131452-sqih5qgls37vxnjh
Tags: 1.7.9-1+nmu2
* Non-maintainer upload.
* Add CVE-2013-1968.patch patch.
  CVE-2013-1968: Subversion FSFS repositories can be corrupted by newline
  characters in filenames. (Closes: #711033)
* Add CVE-2013-2112.patch patch.
  CVE-2013-2112: Fix remotely triggerable DoS vulnerability. (Closes: #711033)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Fix CVE-2013-1968
 
2
 Subversion FSFS repositories can be corrupted by newline characters in
 
3
 filenames.
 
4
Origin: upstream, http://subversion.apache.org/security/CVE-2013-1968-advisory.txt
 
5
Bug-Debian: http://bugs.debian.org/711033
 
6
Forwarded: not-needed
 
7
Author: Salvatore Bonaccorso <carnil@debian.org>
 
8
Last-Update: 2013-06-06
 
9
 
 
10
--- a/subversion/libsvn_fs_fs/tree.c
 
11
+++ b/subversion/libsvn_fs_fs/tree.c
 
12
@@ -44,6 +44,7 @@
 
13
 #include "svn_private_config.h"
 
14
 #include "svn_pools.h"
 
15
 #include "svn_error.h"
 
16
+#include "svn_ctype.h"
 
17
 #include "svn_dirent_uri.h"
 
18
 #include "svn_path.h"
 
19
 #include "svn_mergeinfo.h"
 
20
@@ -1806,6 +1807,78 @@
 
21
   return svn_fs_fs__dag_dir_entries(table_p, node, pool, pool);
 
22
 }
 
23
 
 
24
+/* Return a copy of PATH, allocated from POOL, for which control
 
25
+   characters have been escaped using the form \NNN (where NNN is the
 
26
+   octal representation of the byte's ordinal value).  */
 
27
+static const char *
 
28
+illegal_path_escape(const char *path, apr_pool_t *pool)
 
29
+{
 
30
+  svn_stringbuf_t *retstr;
 
31
+  apr_size_t i, copied = 0;
 
32
+  int c;
 
33
+
 
34
+  /* At least one control character:
 
35
+      strlen - 1 (control) + \ + N + N + N + null . */
 
36
+  retstr = svn_stringbuf_create_ensure(strlen(path) + 4, pool);
 
37
+  for (i = 0; path[i]; i++)
 
38
+    {
 
39
+      c = (unsigned char)path[i];
 
40
+      if (! svn_ctype_iscntrl(c))
 
41
+        continue;
 
42
+
 
43
+      /* If we got here, we're looking at a character that isn't
 
44
+         supported by the (or at least, our) URI encoding scheme.  We
 
45
+         need to escape this character.  */
 
46
+
 
47
+      /* First things first, copy all the good stuff that we haven't
 
48
+         yet copied into our output buffer. */
 
49
+      if (i - copied)
 
50
+        svn_stringbuf_appendbytes(retstr, path + copied,
 
51
+                                  i - copied);
 
52
+
 
53
+      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
 
54
+      svn_stringbuf_ensure(retstr, retstr->len + 5);
 
55
+      /*### The backslash separator doesn't work too great with Windows,
 
56
+         but it's what we'll use for consistency with invalid utf8
 
57
+         formatting (until someone has a better idea) */
 
58
+      apr_snprintf(retstr->data + retstr->len, 5, "\\%03o", (unsigned char)c);
 
59
+      retstr->len += 4;
 
60
+
 
61
+      /* Finally, update our copy counter. */
 
62
+      copied = i + 1;
 
63
+    }
 
64
+
 
65
+  /* If we didn't encode anything, we don't need to duplicate the string. */
 
66
+  if (retstr->len == 0)
 
67
+    return path;
 
68
+
 
69
+  /* Anything left to copy? */
 
70
+  if (i - copied)
 
71
+    svn_stringbuf_appendbytes(retstr, path + copied, i - copied);
 
72
+
 
73
+  /* retstr is null-terminated either by apr_snprintf or the svn_stringbuf
 
74
+     functions. */
 
75
+
 
76
+  return retstr->data;
 
77
+}
 
78
+
 
79
+/* Raise an error if PATH contains a newline because FSFS cannot handle
 
80
+ * such paths. See issue #4340. */
 
81
+static svn_error_t *
 
82
+check_newline(const char *path, apr_pool_t *pool)
 
83
+{
 
84
+  const char *c;
 
85
+
 
86
+  for (c = path; *c; c++)
 
87
+    {
 
88
+      if (*c == '\n')
 
89
+        return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
 
90
+           _("Invalid control character '0x%02x' in path '%s'"),
 
91
+           (unsigned char)*c, illegal_path_escape(path, pool));
 
92
+    }
 
93
+
 
94
+  return SVN_NO_ERROR;
 
95
+}
 
96
 
 
97
 /* Create a new directory named PATH in ROOT.  The new directory has
 
98
    no entries, and no properties.  ROOT must be the root of a
 
99
@@ -1820,6 +1893,8 @@
 
100
   dag_node_t *sub_dir;
 
101
   const char *txn_id = root->txn;
 
102
 
 
103
+  SVN_ERR(check_newline(path, pool));
 
104
+
 
105
   SVN_ERR(open_path(&parent_path, root, path, open_path_last_optional,
 
106
                     txn_id, pool));
 
107
 
 
108
@@ -2082,6 +2157,8 @@
 
109
         const char *to_path,
 
110
         apr_pool_t *pool)
 
111
 {
 
112
+  SVN_ERR(check_newline(to_path, pool));
 
113
+
 
114
   return svn_error_trace(copy_helper(from_root, from_path, to_root, to_path,
 
115
                                      TRUE, pool));
 
116
 }
 
117
@@ -2174,6 +2251,8 @@
 
118
   dag_node_t *child;
 
119
   const char *txn_id = root->txn;
 
120
 
 
121
+  SVN_ERR(check_newline(path, pool));
 
122
+
 
123
   SVN_ERR(open_path(&parent_path, root, path, open_path_last_optional,
 
124
                     txn_id, pool));
 
125