[pywin32-checkins] pywin32/win32/src PySECURITY_DESCRIPTOR.cpp,1.12,1.13
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-01-08 03:14:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31107/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Allow pywintypes.SECURITY_DESCRIPTOR() to accept any buffer object that contains a valid security descriptor Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PySECURITY_DESCRIPTOR.cpp 26 Jul 2004 06:47:16 -0000 1.12 --- PySECURITY_DESCRIPTOR.cpp 8 Jan 2005 03:14:36 -0000 1.13 *************** *** 70,74 **** PyObject *PyWinMethod_NewSECURITY_DESCRIPTOR(PyObject *self, PyObject *args) { ! long descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)) return new PySECURITY_DESCRIPTOR(descriptor_len); --- 70,74 ---- PyObject *PyWinMethod_NewSECURITY_DESCRIPTOR(PyObject *self, PyObject *args) { ! int descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)) return new PySECURITY_DESCRIPTOR(descriptor_len); *************** *** 76,87 **** PyErr_Clear(); PyObject *obsd = NULL; // @pyparmalt1 buffer|data||A buffer (eg, a string) with the raw bytes for the security descriptor. if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd)) return NULL; ! if (!PySECURITY_DESCRIPTOR_Check(obsd)){ ! PyErr_SetString(PyExc_TypeError,"Object is not a PySECURITY_DESCRIPTOR"); return NULL; ! } ! PSECURITY_DESCRIPTOR psd = ((PySECURITY_DESCRIPTOR *)obsd)->GetSD(); return new PySECURITY_DESCRIPTOR(psd); } --- 76,91 ---- PyErr_Clear(); PyObject *obsd = NULL; + PSECURITY_DESCRIPTOR psd; // @pyparmalt1 buffer|data||A buffer (eg, a string) with the raw bytes for the security descriptor. if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd)) return NULL; ! if (PyObject_AsReadBuffer(obsd, (const void **)&psd, &descriptor_len)==-1){ ! PyErr_SetString(PyExc_TypeError,"Object has no data buffer"); return NULL; ! } ! if (!IsValidSecurityDescriptor(psd)){ ! PyErr_SetString(PyExc_ValueError,"Data is not a valid security descriptor"); ! return NULL; ! } return new PySECURITY_DESCRIPTOR(psd); } |