Modified: 
subversion/branches/master-passphrase/subversion/libsvn_subr/win32_crypto.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/win32_crypto.c?rev=1310042&r1=1310041&r2=1310042&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/win32_crypto.c 
(original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/win32_crypto.c 
Thu Apr  5 20:08:20 2012
@@ -28,28 +28,77 @@
 /*** Includes. ***/
 
 #include <apr_pools.h>
+#include <apr_base64.h>
 #include "svn_auth.h"
 #include "svn_error.h"
 #include "svn_utf.h"
 #include "svn_config.h"
 #include "svn_user.h"
+#include "svn_base64.h"
 
 #include "private/svn_auth_private.h"
 
 #include "svn_private_config.h"
 
 #include <wincrypt.h>
-#include <apr_base64.h>
-
-/*-----------------------------------------------------------------------*/
-/* Windows simple provider, encrypts the password on Win2k and later.    */
-/*-----------------------------------------------------------------------*/
 
+
 /* The description string that's combined with unencrypted data by the
    Windows CryptoAPI. Used during decryption to verify that the
    encrypted data were valid. */
 static const WCHAR description[] = L"auth_svn.simple.wincrypt";
 
+
+/* Return a copy of ORIG, encrypted using the Windows CryptoAPI and
+   allocated from POOL. */
+const svn_string_t *
+encrypt_data(const svn_string_t *orig,
+             apr_pool_t *pool)
+{
+  DATA_BLOB blobin;
+  DATA_BLOB blobout;
+  const svn_string_t *crypted = NULL;
+
+  blobin.cbData = orig->len;
+  blobin.pbData = (BYTE *)orig->data;
+  if (CryptProtectData(&blobin, description, NULL, NULL, NULL,
+                       CRYPTPROTECT_UI_FORBIDDEN, &blobout))
+    {
+      crypted = svn_string_ncreate(blobout.pbData, blobout.cbData, pool);
+      LocalFree(blobout.pbData);
+    }
+  return crypted;
+}
+
+/* Return a copy of CRYPTED, decrypted using the Windows CryptoAPI and
+   allocated from POOL. */
+const svn_string_t *
+decrypt_data(const svn_string_t *crypted,
+             apr_pool_t *pool)
+{
+  DATA_BLOB blobin;
+  DATA_BLOB blobout;
+  LPWSTR descr;
+  const svn_string_t *orig = NULL;
+
+  blobin.cbData = crypted->len;
+  blobin.pbData = (BYTE *)crypted->data;
+  if (CryptUnprotectData(&blobin, &descr, NULL, NULL, NULL,
+                         CRYPTPROTECT_UI_FORBIDDEN, &blobout))
+    {
+      if (0 == lstrcmpW(descr, description))
+        orig = svn_string_ncreate(blobout.pbData, blobout.cbData, pool);
+      LocalFree(blobout.pbData);
+      LocalFree(descr);
+    }
+  return orig;
+}
+
+
+/*-----------------------------------------------------------------------*/
+/* Windows simple provider, encrypts the password on Win2k and later.    */
+/*-----------------------------------------------------------------------*/
+
 /* Implementation of svn_auth__password_set_t that encrypts
    the incoming password using the Windows CryptoAPI. */
 static svn_error_t *
@@ -62,22 +111,15 @@ windows_password_encrypter(svn_boolean_t
                            svn_boolean_t non_interactive,
                            apr_pool_t *pool)
 {
-  DATA_BLOB blobin;
-  DATA_BLOB blobout;
-  svn_boolean_t crypted;
+  const svn_string_t *coded;
 
-  blobin.cbData = strlen(in);
-  blobin.pbData = (BYTE*) in;
-  crypted = CryptProtectData(&blobin, description, NULL, NULL, NULL,
-                             CRYPTPROTECT_UI_FORBIDDEN, &blobout);
-  if (crypted)
+  coded = encrypt_data(svn_string_create(in, pool), pool);
+  if (coded)
     {
-      char *coded = apr_palloc(pool, apr_base64_encode_len(blobout.cbData));
-      apr_base64_encode(coded, (const char*)blobout.pbData, blobout.cbData);
+      coded = svn_base64_encode_string2(coded, FALSE, pool);
       SVN_ERR(svn_auth__simple_password_set(done, creds, realmstring, username,
-                                            coded, parameters,
+                                            coded->data, parameters,
                                             non_interactive, pool));
-      LocalFree(blobout.pbData);
     }
 
   return SVN_NO_ERROR;
@@ -96,33 +138,25 @@ windows_password_decrypter(svn_boolean_t
                            svn_boolean_t non_interactive,
                            apr_pool_t *pool)
 {
-  DATA_BLOB blobin;
-  DATA_BLOB blobout;
-  LPWSTR descr;
-  svn_boolean_t decrypted;
-  char *in;
+  const svn_string_t *orig;
+  const char *in;
 
   SVN_ERR(svn_auth__simple_password_get(done, &in, creds, realmstring, 
username,
                                         parameters, non_interactive, pool));
   if (!done)
     return SVN_NO_ERROR;
 
-  blobin.cbData = strlen(in);
-  blobin.pbData = apr_palloc(pool, apr_base64_decode_len(in));
-  apr_base64_decode((char*)blobin.pbData, in);
-  decrypted = CryptUnprotectData(&blobin, &descr, NULL, NULL, NULL,
-                                 CRYPTPROTECT_UI_FORBIDDEN, &blobout);
-  if (decrypted)
+  orig = svn_base64_decode_string(svn_string_create(in, pool), pool);
+  orig = decrypt_data(orig, pool);
+  if (orig)
     {
-      if (0 == lstrcmpW(descr, description))
-        *out = apr_pstrndup(pool, (const char*)blobout.pbData, blobout.cbData);
-      else
-        decrypted = FALSE;
-      LocalFree(blobout.pbData);
-      LocalFree(descr);
+      *out = orig->data;
+      *done = TRUE;
+    }
+  else
+    {
+      *done = FALSE;
     }
-
-  *done = decrypted;
   return SVN_NO_ERROR;
 }
 
@@ -200,22 +234,16 @@ windows_ssl_client_cert_pw_encrypter(svn
                                      svn_boolean_t non_interactive,
                                      apr_pool_t *pool)
 {
-  DATA_BLOB blobin;
-  DATA_BLOB blobout;
-  svn_boolean_t crypted;
+  const svn_string_t *coded;
 
-  blobin.cbData = strlen(in);
-  blobin.pbData = (BYTE*) in;
-  crypted = CryptProtectData(&blobin, description, NULL, NULL, NULL,
-                             CRYPTPROTECT_UI_FORBIDDEN, &blobout);
-  if (crypted)
+  coded = encrypt_data(svn_string_create(in, pool), pool);
+  if (coded)
     {
-      char *coded = apr_palloc(pool, apr_base64_encode_len(blobout.cbData));
-      apr_base64_encode(coded, (const char*)blobout.pbData, blobout.cbData);
+      coded = svn_base64_encode_string2(coded, FALSE, pool);
       SVN_ERR(svn_auth__ssl_client_cert_pw_set(done, creds, realmstring,
-                                               username, coded, parameters,
-                                               non_interactive, pool));
-      LocalFree(blobout.pbData);
+                                               username, coded->data,
+                                               parameters, non_interactive,
+                                               pool));
     }
 
   return SVN_NO_ERROR;
@@ -234,11 +262,8 @@ windows_ssl_client_cert_pw_decrypter(svn
                                      svn_boolean_t non_interactive,
                                      apr_pool_t *pool)
 {
-  DATA_BLOB blobin;
-  DATA_BLOB blobout;
-  LPWSTR descr;
-  svn_boolean_t decrypted;
-  char *in;
+  const svn_string_t *orig;
+  const char *in;
 
   SVN_ERR(svn_auth__ssl_client_cert_pw_get(done, &in, creds, realmstring,
                                            username, parameters,
@@ -246,22 +271,17 @@ windows_ssl_client_cert_pw_decrypter(svn
   if (!done)
     return SVN_NO_ERROR;
 
-  blobin.cbData = strlen(in);
-  blobin.pbData = apr_palloc(pool, apr_base64_decode_len(in));
-  apr_base64_decode((char*)blobin.pbData, in);
-  decrypted = CryptUnprotectData(&blobin, &descr, NULL, NULL, NULL,
-                                 CRYPTPROTECT_UI_FORBIDDEN, &blobout);
-  if (decrypted)
+  orig = svn_base64_decode_string(svn_string_create(in, pool), pool);
+  orig = decrypt_data(orig, pool);
+  if (orig)
     {
-      if (0 == lstrcmpW(descr, description))
-        *out = apr_pstrndup(pool, (const char*)blobout.pbData, blobout.cbData);
-      else
-        decrypted = FALSE;
-      LocalFree(blobout.pbData);
-      LocalFree(descr);
+      *out = orig->data;
+      *done = TRUE;
+    }
+  else
+    {
+      *done = FALSE;
     }
-
-  *done = decrypted;
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/master-passphrase/subversion/svndumpfilter/main.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/svndumpfilter/main.c?rev=1310042&r1=1310041&r2=1310042&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/svndumpfilter/main.c 
(original)
+++ subversion/branches/master-passphrase/subversion/svndumpfilter/main.c Thu 
Apr  5 20:08:20 2012
@@ -79,7 +79,7 @@ create_stdio_stream(svn_stream_t **strea
 
 /* Writes a property in dumpfile format to given stringbuf. */
 static void
-write_prop_to_stringbuf(svn_stringbuf_t **strbuf,
+write_prop_to_stringbuf(svn_stringbuf_t *strbuf,
                         const char *name,
                         const svn_string_t *value)
 {
@@ -89,24 +89,24 @@ write_prop_to_stringbuf(svn_stringbuf_t 
 
   /* Output name length, then name. */
   namelen = strlen(name);
-  svn_stringbuf_appendbytes(*strbuf, "K ", 2);
+  svn_stringbuf_appendbytes(strbuf, "K ", 2);
 
   bytes_used = apr_snprintf(buf, sizeof(buf), "%" APR_SIZE_T_FMT, namelen);
-  svn_stringbuf_appendbytes(*strbuf, buf, bytes_used);
-  svn_stringbuf_appendbyte(*strbuf, '\n');
+  svn_stringbuf_appendbytes(strbuf, buf, bytes_used);
+  svn_stringbuf_appendbyte(strbuf, '\n');
 
-  svn_stringbuf_appendbytes(*strbuf, name, namelen);
-  svn_stringbuf_appendbyte(*strbuf, '\n');
+  svn_stringbuf_appendbytes(strbuf, name, namelen);
+  svn_stringbuf_appendbyte(strbuf, '\n');
 
   /* Output value length, then value. */
-  svn_stringbuf_appendbytes(*strbuf, "V ", 2);
+  svn_stringbuf_appendbytes(strbuf, "V ", 2);
 
   bytes_used = apr_snprintf(buf, sizeof(buf), "%" APR_SIZE_T_FMT, value->len);
-  svn_stringbuf_appendbytes(*strbuf, buf, bytes_used);
-  svn_stringbuf_appendbyte(*strbuf, '\n');
+  svn_stringbuf_appendbytes(strbuf, buf, bytes_used);
+  svn_stringbuf_appendbyte(strbuf, '\n');
 
-  svn_stringbuf_appendbytes(*strbuf, value->data, value->len);
-  svn_stringbuf_appendbyte(*strbuf, '\n');
+  svn_stringbuf_appendbytes(strbuf, value->data, value->len);
+  svn_stringbuf_appendbyte(strbuf, '\n');
 }
 
 
@@ -364,7 +364,7 @@ output_revision(struct revision_baton_t 
           const char *pname = svn__apr_hash_index_key(hi);
           const svn_string_t *pval = svn__apr_hash_index_val(hi);
 
-          write_prop_to_stringbuf(&props, pname, pval);
+          write_prop_to_stringbuf(props, pname, pval);
         }
       svn_stringbuf_appendcstr(props, "PROPS-END\n");
       svn_stringbuf_appendcstr(rb->header,
@@ -804,7 +804,7 @@ set_node_property(void *node_baton,
       value = filtered_mergeinfo;
     }
 
-  write_prop_to_stringbuf(&(nb->props), name, value);
+  write_prop_to_stringbuf(nb->props, name, value);
 
   return SVN_NO_ERROR;
 }

Modified: 
subversion/branches/master-passphrase/subversion/tests/cmdline/copy_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/tests/cmdline/copy_tests.py?rev=1310042&r1=1310041&r2=1310042&view=diff
==============================================================================
--- 
subversion/branches/master-passphrase/subversion/tests/cmdline/copy_tests.py 
(original)
+++ 
subversion/branches/master-passphrase/subversion/tests/cmdline/copy_tests.py 
Thu Apr  5 20:08:20 2012
@@ -25,7 +25,9 @@
 ######################################################################
 
 # General modules
-import stat, os, re, shutil
+import stat, os, re, shutil, logging
+
+logger = logging.getLogger()
 
 # Our testing module
 import svntest
@@ -812,7 +814,7 @@ def copy_preserve_executable_bit(sbox):
   mode2 = os.stat(newpath1)[stat.ST_MODE]
 
   if mode1 == mode2:
-    print("setting svn:executable did not change file's permissions")
+    logger.warn("setting svn:executable did not change file's permissions")
     raise svntest.Failure
 
   # Commit the file
@@ -827,7 +829,7 @@ def copy_preserve_executable_bit(sbox):
 
   # The mode on the original and copied file should be identical
   if mode2 != mode3:
-    print("permissions on the copied file are not identical to original file")
+    logger.warn("permissions on the copied file are not identical to original 
file")
     raise svntest.Failure
 
 #----------------------------------------------------------------------
@@ -942,13 +944,13 @@ def repos_to_wc(sbox):
   # Modification will only show up if timestamps differ
   exit_code, out, err = svntest.main.run_svn(None, 'diff', pi_path)
   if err or not out:
-    print("diff failed")
+    logger.warn("diff failed")
     raise svntest.Failure
   for line in out:
     if line == '+zig\n': # Crude check for diff-like output
       break
   else:
-    print("diff output incorrect %s" % out)
+    logger.warn("diff output incorrect %s" % out)
     raise svntest.Failure
 
   # Revert everything and verify.
@@ -1367,7 +1369,7 @@ def revision_kinds_local_source(sbox):
       if line.rstrip() == "Copied From Rev: " + str(from_rev):
         break
     else:
-      print("%s should have been copied from revision %s" % (dst, from_rev))
+      logger.warn("%s should have been copied from revision %s" % (dst, 
from_rev))
       raise svntest.Failure
 
   # Check that the new files have the right contents
@@ -1625,7 +1627,7 @@ def url_to_non_existent_url_path(sbox):
     if re.match (msg, err_line):
       break
   else:
-    print("message \"%s\" not found in error output: %s" % (msg, err))
+    logger.warn("message \"%s\" not found in error output: %s" % (msg, err))
     raise svntest.Failure
 
 

Modified: 
subversion/branches/master-passphrase/subversion/tests/cmdline/log_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/tests/cmdline/log_tests.py?rev=1310042&r1=1310041&r2=1310042&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/tests/cmdline/log_tests.py 
(original)
+++ subversion/branches/master-passphrase/subversion/tests/cmdline/log_tests.py 
Thu Apr  5 20:08:20 2012
@@ -2217,8 +2217,8 @@ def log_xml_old(sbox):
                                          expected_paths=paths)
 
 
-@XFail()
 @Issue(4153)
+@XFail(svntest.main.is_ra_type_dav)
 def log_diff_moved(sbox):
   "log --diff on moved file"
 


Reply via email to