Rev 1641: More paranoia error checks. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sun Aug 24 17:44:24 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1641
revision-id: jelmer at samba.org-20080824164421-y7970d3k6xi48lry
parent: jelmer at samba.org-20080824164414-e9fanwhdie2vwhcw
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-08-24 18:44:21 +0200
message:
  More paranoia error checks.
modified:
  ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
  util.c                         util.c-20080531154025-s8ef6ej9tytsnkkw-1
=== modified file 'ra.c'
--- a/ra.c	2008-08-24 16:16:14 +0000
+++ b/ra.c	2008-08-24 16:44:21 +0000
@@ -1284,11 +1284,11 @@
 	if (ra_check_busy(ra))
 		return NULL;
 
-	Py_BEGIN_ALLOW_THREADS
 #if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
 	hash_revprops = prop_dict_to_hash(pool, revprops);
 	if (hash_revprops == NULL)
 		return NULL;
+	Py_BEGIN_ALLOW_THREADS
 	err = svn_ra_get_commit_editor3(ra->ra, &editor, 
 		&edit_baton, 
 		hash_revprops, py_commit_callback, 
@@ -1311,6 +1311,7 @@
 		return NULL;
 	}
 
+	Py_BEGIN_ALLOW_THREADS
 	err = svn_ra_get_commit_editor2(ra->ra, &editor, 
 		&edit_baton, 
 		PyString_AsString(py_log_msg), py_commit_callback, 

=== modified file 'util.c'
--- a/util.c	2008-08-24 14:51:43 +0000
+++ b/util.c	2008-08-24 16:44:21 +0000
@@ -155,13 +155,35 @@
 {
 	Py_ssize_t idx = 0;
 	PyObject *k, *v;
-	apr_hash_t *hash_props = apr_hash_make(pool);
-	if (hash_props == NULL)
-		return NULL;
+	apr_hash_t *hash_props;
+	svn_string_t *val_string;
+
+	if (!PyDict_Check(py_props)) {
+		PyErr_SetString(PyExc_TypeError, "props should be dictionary");
+		return NULL;
+	}
+
+	hash_props = apr_hash_make(pool);
+	if (hash_props == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
 	while (PyDict_Next(py_props, &idx, &k, &v)) {
-		svn_string_t *val_string = svn_string_ncreate(PyString_AsString(v), 
-													  PyString_Size(v),
-													  pool);
+
+		if (!PyString_Check(k)) {
+			PyErr_SetString(PyExc_TypeError, 
+							"property name should be string");
+			return NULL;
+		}
+		if (!PyString_Check(v)) {
+			PyErr_SetString(PyExc_TypeError, 
+							"property value should be string");
+			return NULL;
+		}
+
+		val_string = svn_string_ncreate(PyString_AsString(v), 
+										PyString_Size(v), pool);
 		apr_hash_set(hash_props, PyString_AsString(k), 
 					 PyString_Size(k), val_string);
 	}




More information about the bazaar-commits mailing list