Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libselinux: wrong swig code for security_load_policy(3) #354

Open
cgzones opened this issue May 20, 2022 · 0 comments
Open

libselinux: wrong swig code for security_load_policy(3) #354

cgzones opened this issue May 20, 2022 · 0 comments

Comments

@cgzones
Copy link
Contributor

cgzones commented May 20, 2022

The swig typemap

%typemap(in,noblock=1,numinputs=0) char ** (char * temp = 0) {
$1 = &temp;
}
added in 9639f5d leads to wrong wrapper code being generated:

selinux.py:

def security_load_policy(len):
    return _selinux.security_load_policy(len)

selinuxswig_python_wrap.c:

SWIGINTERN PyObject *_wrap_security_load_policy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = 0;
  void *arg1 = (void *) 0 ;
  size_t arg2 ;
  char *temp1 = NULL ;
  size_t val2 ;
  int ecode2 = 0 ;
  PyObject *swig_obj[1] ;
  int result;

  {
    arg1 = temp1;  // <- assignment to NULL
  }
  if (!args) SWIG_fail;
  swig_obj[0] = args;
  ecode2 = SWIG_AsVal_size_t(swig_obj[0], &val2);
  if (!SWIG_IsOK(ecode2)) {
    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "security_load_policy" "', argument " "2"" of type '" "size_t""'");
  }
  arg2 = (size_t)(val2);
  {
    result = (int)security_load_policy(arg1,arg2);  // <- arg1 is always NULL
    if (result < 0) {
      PyErr_SetFromErrno(PyExc_OSError);
      SWIG_fail;
    }
  }
  resultobj = SWIG_From_int((int)(result));
  return resultobj;
fail:
  return NULL;
}

The typemap might have been indented for selinux_getenforcemode(3) only but does affect many more functions, e.g. selinux_check_access(3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant