[PATCH] pylibsmb: Avoid a segfault if no credentials are passed to libsmb.Conn()

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Apr 9 06:55:34 MDT 2013


Hi!

Please 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 81636a568c91b8bbfa98d50f283b8343384a8dee Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 9 Apr 2013 14:29:11 +0200
Subject: [PATCH] pylibsmb: Avoid a segfault if no credentials are passed to libsmb.Conn()

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libsmb/pylibsmb.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index 4fd5921..2b253f9 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -406,7 +406,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
 {
 	NTSTATUS status;
 	char *host, *share;
-	PyObject *creds;
+	PyObject *creds = NULL;
 	struct cli_credentials *cli_creds;
 	bool ret;
 
@@ -434,10 +434,10 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args,
 		return -1;
 	}
 
-	cli_creds = cli_credentials_from_py_object(creds);
-	if (cli_creds == NULL) {
-		PyErr_SetString(PyExc_TypeError, "Expected credentials");
-		return -1;
+	if (creds == NULL) {
+		cli_creds = cli_credentials_init_anon(NULL);
+	} else {
+		cli_creds = PyCredentials_AsCliCredentials(creds);
 	}
 
 	status = cli_full_connection(
-- 
1.7.3.4



More information about the samba-technical mailing list