[PATCH] Fix a crash on FreeBSD10/clang

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Nov 27 04:33:06 MST 2014


Hi!

I'd appreciate review&push!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From b973929ae57451ae99188d0b5628228661cc2017 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 27 Nov 2014 12:28:40 +0100
Subject: [PATCH] messaging4: Fix types

According to python docs, PyArg_ParseTuple takes "int" and "unsigned
long long". With pointers down to functions, in particular with
varargs, there is no automatic conversion. So we need to be very
strict about types. Automatic conversion to for example uint64_t
happes only with assignment.

This fixes a crash on FreeBSD10/clang.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/lib/messaging/pymessaging.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c
index 1e9588c..199532f 100644
--- a/source4/lib/messaging/pymessaging.c
+++ b/source4/lib/messaging/pymessaging.c
@@ -51,9 +51,19 @@ static bool server_id_from_py(PyObject *object, struct server_id *server_id)
 		return true;
 	}
 	if (PyTuple_Size(object) == 3) {
-		return PyArg_ParseTuple(object, "KII", &server_id->pid, &server_id->task_id, &server_id->vnn);
+		unsigned long long pid;
+		int task_id, vnn;
+
+		if (!PyArg_ParseTuple(object, "KII", &pid, &task_id, &vnn)) {
+			return false;
+		}
+		server_id->pid = pid;
+		server_id->task_id = task_id;
+		server_id->vnn = vnn;
+		return true;
 	} else {
-		int pid, task_id;
+		unsigned long long pid;
+		int task_id;
 		if (!PyArg_ParseTuple(object, "KI", &pid, &task_id))
 			return false;
 		*server_id = cluster_id(pid, task_id);
-- 
2.1.0



More information about the samba-technical mailing list