Skip to content

Commit

Permalink
#3148 memset so we can check the buffer pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 31, 2021
1 parent ae56b87 commit 7f9ca3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xpra/server/pam.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ from xpra.os_util import strtobytes, bytestostr
from ctypes import addressof, create_string_buffer, sizeof

from libc.stdint cimport uintptr_t #pylint: disable=syntax-error
from libc.string cimport memset

ctypedef void* void_p # @UndefinedVariable
ctypedef const void* const_void_p # @UndefinedVariable
Expand Down Expand Up @@ -156,6 +157,7 @@ cdef class pam_session:
def start(self, password=False) -> bool:
cdef pam_conv conv
cdef Py_buffer view
memset(&view, 0, sizeof(Py_buffer))

if self.pam_handle!=NULL:
log.error("Error: cannot open the pam session more than once!")
Expand All @@ -174,7 +176,7 @@ cdef class pam_session:
try:
pam_start(strtobytes(self.service_name), strtobytes(self.username), &conv, &self.pam_handle)
finally:
if view!=NULL:
if view.buf!=NULL:
PyBuffer_Release(&view)
log("pam_start: %s", PAM_ERR_STR.get(r, r))
if r!=PAM_SUCCESS:
Expand Down

0 comments on commit 7f9ca3d

Please sign in to comment.