Make the debug subsystem unsigned.

It was already unsigned in sudoers but not in the front-end or the
python plugin.  Making this consistent resolves a lot of -Wconversion
warnings.  Also clean up some other -Wconversion warnings in sudo_debug.c.
This commit is contained in:
Todd C. Miller
2023-07-01 16:14:50 -06:00
parent 04c7e910ef
commit b926df1df2
7 changed files with 121 additions and 104 deletions

View File

@@ -321,7 +321,7 @@ done:
static void
_py_debug_python_function(const char *class_name, const char *function_name, const char *message,
PyObject *py_args, PyObject *py_kwargs, int subsystem_id)
PyObject *py_args, PyObject *py_kwargs, unsigned int subsystem_id)
{
debug_decl_vars(_py_debug_python_function, subsystem_id);
@@ -373,7 +373,8 @@ _py_debug_python_function(const char *class_name, const char *function_name, con
void
py_debug_python_call(const char *class_name, const char *function_name,
PyObject *py_args, PyObject *py_kwargs, int subsystem_id)
PyObject *py_args, PyObject *py_kwargs,
unsigned int subsystem_id)
{
debug_decl_vars(py_debug_python_call, subsystem_id);
@@ -397,7 +398,7 @@ py_debug_python_call(const char *class_name, const char *function_name,
void
py_debug_python_result(const char *class_name, const char *function_name,
PyObject *py_result, int subsystem_id)
PyObject *py_result, unsigned int subsystem_id)
{
if (py_result == NULL) {
debug_decl_vars(py_debug_python_result, subsystem_id);

View File

@@ -94,9 +94,10 @@ void py_object_set_attr_string(PyObject *py_object, const char *attr_name, const
PyObject *py_create_version(unsigned int version);
void py_debug_python_call(const char *class_name, const char *function_name,
PyObject *py_args, PyObject *py_kwargs, int subsystem_id);
PyObject *py_args, PyObject *py_kwargs,
unsigned int subsystem_id);
void py_debug_python_result(const char *class_name, const char *function_name,
PyObject *py_args, int subsystem_id);
PyObject *py_args, unsigned int subsystem_id);
void str_array_free(char ***array);

View File

@@ -27,7 +27,7 @@ PyObject *sudo_type_LogHandler;
static void
_debug_plugin(int log_level, const char *log_message)
_debug_plugin(unsigned int log_level, const char *log_message)
{
debug_decl_vars(python_sudo_debug, PYTHON_DEBUG_PLUGIN);
@@ -54,7 +54,7 @@ python_sudo_debug(PyObject *Py_UNUSED(py_self), PyObject *py_args)
debug_decl(python_sudo_debug, PYTHON_DEBUG_C_CALLS);
py_debug_python_call("sudo", "debug", py_args, NULL, PYTHON_DEBUG_C_CALLS);
int log_level = SUDO_DEBUG_DEBUG;
unsigned int log_level = SUDO_DEBUG_DEBUG;
const char *log_message = NULL;
if (!PyArg_ParseTuple(py_args, "is:sudo.debug", &log_level, &log_message)) {
debug_return_ptr(NULL);
@@ -65,7 +65,7 @@ python_sudo_debug(PyObject *Py_UNUSED(py_self), PyObject *py_args)
debug_return_ptr_pynone;
}
static int
static unsigned int
_sudo_log_level_from_python(long level)
{
if (level >= 50)
@@ -99,7 +99,7 @@ _sudo_LogHandler__emit(PyObject *py_self, PyObject *py_args)
goto cleanup;
}
int sudo_loglevel = _sudo_log_level_from_python(python_loglevel);
unsigned int sudo_loglevel = _sudo_log_level_from_python(python_loglevel);
py_message = PyObject_CallMethod(py_self, "format", "O", py_record);
if (py_message == NULL)

View File

@@ -51,7 +51,7 @@ static const char *const python_subsystem_names[] = {
#define NUM_SUBSYSTEMS sizeof(python_subsystem_names) / sizeof(*python_subsystem_names) - 1
/* Subsystem IDs assigned at registration time. */
int python_subsystem_ids[NUM_SUBSYSTEMS];
unsigned int python_subsystem_ids[NUM_SUBSYSTEMS];
/*
* Parse the "filename flags,..." debug_flags entry and insert a new
@@ -84,7 +84,7 @@ python_debug_register(const char *program,
if (debug_files != NULL && !TAILQ_EMPTY(debug_files)) {
if (program != NULL) {
instance = sudo_debug_register(program, python_subsystem_names,
(unsigned int *)python_subsystem_ids, debug_files, -1);
python_subsystem_ids, debug_files, -1);
}
TAILQ_FOREACH_SAFE(debug_file, debug_files, entries, debug_next) {
TAILQ_REMOVE(debug_files, debug_file, entries);

View File

@@ -25,7 +25,7 @@
* Sudo python plugin debug subsystems.
* Note that python_subsystem_ids[] is filled in at debug registration time.
*/
extern int python_subsystem_ids[];
extern unsigned int python_subsystem_ids[];
#define PYTHON_DEBUG_PY_CALLS (python_subsystem_ids[0])
#define PYTHON_DEBUG_C_CALLS (python_subsystem_ids[1])
#define PYTHON_DEBUG_PLUGIN_LOAD (python_subsystem_ids[2])