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

« back to all changes in this revision

Viewing changes to subversion/libsvn_subr/subst.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include "svn_private_config.h"
51
51
 
52
52
#include "private/svn_string_private.h"
 
53
#include "private/svn_eol_private.h"
53
54
 
54
55
/**
55
56
 * The textual elements of a detranslated special file.  One of these
127
128
 *
128
129
 * Important API note: This function is the core of the implementation of
129
130
 * svn_subst_build_keywords (all versions), and as such must implement the
130
 
 * tolerance of NULL and zero inputs that that function's documention
 
131
 * tolerance of NULL and zero inputs that that function's documentation
131
132
 * stipulates.
132
133
 *
133
134
 * The format codes:
158
159
               const char *author,
159
160
               apr_pool_t *pool)
160
161
{
161
 
  svn_stringbuf_t *value = svn_stringbuf_ncreate("", 0, pool);
 
162
  svn_stringbuf_t *value = svn_stringbuf_create_empty(pool);
162
163
  const char *cur;
163
164
  size_t n;
164
165
 
1122
1123
              /* skip current EOL */
1123
1124
              len += b->eol_str_len;
1124
1125
 
1125
 
              /* Check 4 bytes at once to allow for efficient pipelining
1126
 
                 and to reduce loop condition overhead. */
1127
 
              while ((p + len + 4) <= end)
1128
 
                {
1129
 
                  if (interesting[(unsigned char)p[len]]
1130
 
                      || interesting[(unsigned char)p[len+1]]
1131
 
                      || interesting[(unsigned char)p[len+2]]
1132
 
                      || interesting[(unsigned char)p[len+3]])
1133
 
                    break;
1134
 
 
1135
 
                  len += 4;
1136
 
                }
1137
 
 
1138
 
               /* Found an interesting char or EOF in the next 4 bytes.
1139
 
                  Find its exact position. */
1140
 
               while ((p + len) < end && !interesting[(unsigned char)p[len]])
1141
 
                 ++len;
 
1126
              if (b->keywords)
 
1127
                {
 
1128
                  /* Check 4 bytes at once to allow for efficient pipelining
 
1129
                    and to reduce loop condition overhead. */
 
1130
                  while ((p + len + 4) <= end)
 
1131
                    {
 
1132
                      if (interesting[(unsigned char)p[len]]
 
1133
                          || interesting[(unsigned char)p[len+1]]
 
1134
                          || interesting[(unsigned char)p[len+2]]
 
1135
                          || interesting[(unsigned char)p[len+3]])
 
1136
                        break;
 
1137
 
 
1138
                      len += 4;
 
1139
                    }
 
1140
 
 
1141
                  /* Found an interesting char or EOF in the next 4 bytes.
 
1142
                     Find its exact position. */
 
1143
                  while ((p + len) < end
 
1144
                         && !interesting[(unsigned char)p[len]])
 
1145
                    ++len;
 
1146
                }
 
1147
              else
 
1148
                {
 
1149
                  /* use our optimized sub-routine to find the next EOL */
 
1150
                  const char *start = p + len;
 
1151
                  const char *eol
 
1152
                    = svn_eol__find_eol_start((char *)start, end - start);
 
1153
 
 
1154
                  /* EOL will be NULL if we did not find a line ending */
 
1155
                  len += (eol ? eol : end) - start;
 
1156
                }
1142
1157
            }
1143
1158
          while (b->nl_translation_skippable ==
1144
1159
                   svn_tristate_true &&       /* can potentially skip EOLs */
1145
1160
                 p + len + 2 < end &&         /* not too close to EOF */
1146
 
                 eol_unchanged (b, p + len)); /* EOL format already ok */
 
1161
                 eol_unchanged(b, p + len));  /* EOL format already ok */
1147
1162
 
1148
1163
          while ((p + len) < end && !interesting[(unsigned char)p[len]])
1149
1164
            len++;
1276
1291
 
1277
1292
          svn_stringbuf_setempty(b->readbuf);
1278
1293
          b->readbuf_off = 0;
1279
 
          SVN_ERR(svn_stream_read(b->stream, b->buf, &readlen));
 
1294
          SVN_ERR(svn_stream_read_full(b->stream, b->buf, &readlen));
1280
1295
          buf_stream = svn_stream_from_stringbuf(b->readbuf, b->iterpool);
1281
1296
 
1282
1297
          SVN_ERR(translate_chunk(buf_stream, b->in_baton, b->buf,
1527
1542
  baton->buf = apr_palloc(result_pool, SVN__TRANSLATION_BUF_SIZE);
1528
1543
 
1529
1544
  /* Setup the stream methods */
1530
 
  svn_stream_set_read(s, translated_stream_read);
 
1545
  svn_stream_set_read2(s, NULL /* only full read support */,
 
1546
                       translated_stream_read);
1531
1547
  svn_stream_set_write(s, translated_stream_write);
1532
1548
  svn_stream_set_close(s, translated_stream_close);
1533
1549
  svn_stream_set_mark(s, translated_stream_mark);
1697
1713
    }
1698
1714
 
1699
1715
  /* If nothing else worked, write out the internal representation to
1700
 
     a file that can be edited by the user.
1701
 
 
1702
 
     ### this only writes the first line!
1703
 
  */
 
1716
     a file that can be edited by the user. */
1704
1717
  if (create_using_internal_representation)
1705
1718
    {
1706
 
      apr_file_t *new_file;
1707
 
      SVN_ERR(svn_io_open_unique_file3(&new_file, &dst_tmp,
1708
 
                                       svn_dirent_dirname(dst, pool),
1709
 
                                       svn_io_file_del_none,
1710
 
                                       pool, pool));
1711
 
 
1712
 
      SVN_ERR(svn_io_file_write_full(new_file,
1713
 
                                     contents->data, contents->len, NULL,
1714
 
                                     pool));
1715
 
 
1716
 
      SVN_ERR(svn_io_file_close(new_file, pool));
 
1719
      svn_stream_t *new_stream;
 
1720
      apr_size_t len;
 
1721
 
 
1722
      SVN_ERR(svn_stream_open_unique(&new_stream, &dst_tmp,
 
1723
                                     svn_dirent_dirname(dst, pool),
 
1724
                                     svn_io_file_del_none,
 
1725
                                     pool, pool));
 
1726
 
 
1727
      if (!eof)
 
1728
        svn_stringbuf_appendcstr(contents, "\n");
 
1729
      len = contents->len;
 
1730
      SVN_ERR(svn_stream_write(new_stream, contents->data, &len));
 
1731
      SVN_ERR(svn_stream_copy3(svn_stream_disown(source, pool), new_stream,
 
1732
                               NULL, NULL, pool));
1717
1733
    }
1718
1734
 
1719
1735
  /* Do the atomic rename from our temporary location. */
1720
 
  return svn_io_file_rename(dst_tmp, dst, pool);
 
1736
  return svn_error_trace(svn_io_file_rename(dst_tmp, dst, pool));
1721
1737
}
1722
1738
 
1723
1739
 
1765
1781
              SVN_ERR(svn_stream_open_readonly(&src_stream, src, pool, pool));
1766
1782
            }
1767
1783
 
1768
 
          return svn_error_trace(create_special_file_from_stream(src_stream,
1769
 
                                                                 dst, pool));
 
1784
          SVN_ERR(create_special_file_from_stream(src_stream, dst, pool));
 
1785
 
 
1786
          return svn_error_trace(svn_stream_close(src_stream));
1770
1787
        }
1771
1788
      /* else !expand */
1772
1789
 
1835
1852
 
1836
1853
  if (btn->read_stream)
1837
1854
    /* We actually found a file to read from */
1838
 
    return svn_stream_read(btn->read_stream, buffer, len);
 
1855
    return svn_stream_read_full(btn->read_stream, buffer, len);
1839
1856
  else
1840
1857
    return svn_error_createf(APR_ENOENT, NULL,
1841
 
                             "Can't read special file: File '%s' not found",
 
1858
                             _("Can't read special file: File '%s' not found"),
1842
1859
                             svn_dirent_local_style(btn->path, btn->pool));
1843
1860
}
1844
1861
 
1925
1942
  baton->write_stream = svn_stream_from_stringbuf(baton->write_content, pool);
1926
1943
 
1927
1944
  *stream = svn_stream_create(baton, pool);
1928
 
  svn_stream_set_read(*stream, read_handler_special);
 
1945
  svn_stream_set_read2(*stream, NULL /* only full read support */,
 
1946
                       read_handler_special);
1929
1947
  svn_stream_set_write(*stream, write_handler_special);
1930
1948
  svn_stream_set_close(*stream, close_handler_special);
1931
1949
 
1954
1972
      return SVN_NO_ERROR;
1955
1973
    }
1956
1974
 
1957
 
  if (encoding && !strcmp(encoding, "UTF-8")) 
 
1975
  if (encoding && !strcmp(encoding, "UTF-8"))
1958
1976
    {
1959
1977
      val_utf8 = value->data;
1960
1978
    }