iscsi-initiator-utils/open-iscsi-2.0-870.1-485217.patch

39 lines
1.4 KiB
Diff
Raw Normal View History

diff -up open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c
--- open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~ 2009-02-12 15:30:52.000000000 +0100
+++ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c 2009-02-12 15:48:30.000000000 +0100
@@ -485,19 +485,28 @@ static PyObject *pylibiscsi_discover_sen
char *kwlist[] = {"address", "port", "authinfo", NULL};
const char *address = NULL;
int i, nr_found, port = 3260;
- PyIscsiChapAuthInfo *pyauthinfo = NULL;
+ PyObject *authinfo_arg = NULL;
const struct libiscsi_auth_info *authinfo = NULL;
struct libiscsi_node *found_nodes;
PyObject* found_node_list;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO!",
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO",
kwlist, &address, &port,
- &PyIscsiChapAuthInfo_Type,
- &pyauthinfo))
+ &authinfo_arg))
return NULL;
- if (pyauthinfo)
- authinfo = &pyauthinfo->info;
+ if (authinfo_arg) {
+ if (PyObject_IsInstance(authinfo_arg, (PyObject *)
+ &PyIscsiChapAuthInfo_Type)) {
+ PyIscsiChapAuthInfo *pyauthinfo =
+ (PyIscsiChapAuthInfo *)authinfo_arg;
+ authinfo = &pyauthinfo->info;
+ } else if (authinfo_arg != Py_None) {
+ PyErr_SetString(PyExc_ValueError,
+ "invalid authinfo type");
+ return NULL;
+ }
+ }
if (libiscsi_discover_sendtargets(context, address, port, authinfo,
&nr_found, &found_nodes)) {