python plugin: silence -Wconversion warnings.

This commit is contained in:
Todd C. Miller
2023-07-07 15:07:04 -06:00
parent a38b714667
commit 0c85f10c80
5 changed files with 9 additions and 7 deletions

View File

@@ -205,7 +205,7 @@ py_str_array_from_tuple(PyObject *py_tuple)
Py_ssize_t tuple_size = PyTuple_Size(py_tuple);
// we need an extra 0 at the end
char **result = calloc(tuple_size + 1, sizeof(char *));
char **result = calloc((size_t)tuple_size + 1, sizeof(char *));
if (result == NULL) {
debug_return_ptr(NULL);
}

View File

@@ -137,7 +137,7 @@ sudo_module_ConvMessages_to_c(PyObject *py_tuple, Py_ssize_t *num_msgs, struct s
debug_return_int(SUDO_RC_ERROR);
}
*msgs = calloc(*num_msgs, sizeof(struct sudo_conv_message));
*msgs = calloc((size_t)*num_msgs, sizeof(struct sudo_conv_message));
if (*msgs == NULL) {
debug_return_int(SUDO_RC_ERROR);
}

View File

@@ -149,7 +149,7 @@ str_replaced(const char *source, size_t dest_len, const char *old, const char *n
return NULL;
while ((pos = strstr(source, old)) != NULL) {
size_t len = snprintf(dest, dest_len,
size_t len = (size_t)snprintf(dest, dest_len,
"%.*s%s", (int)(pos - source), source, new);
if (len >= dest_len)
goto fail;

View File

@@ -42,7 +42,7 @@ remove_underline(char *output)
size_t len = strspn(cp, "^ \t");
if (len > 0 && cp[len] == '\n') {
/* Prune out lines that are "underlining". */
memmove(cp, cp + len + 1, ep - cp);
memmove(cp, cp + len + 1, (size_t)(ep - cp));
if (*cp == '\0')
break;
} else {
@@ -238,8 +238,10 @@ verify_log_lines(const char *reference_path)
line_data += 2;
char *line_end = strstr(line_data, " object at "); // this skips checking the pointer hex
if (line_end)
snprintf(line_end, sizeof(line) - (line_end - line), " object>\n");
if (line_end) {
snprintf(line_end, sizeof(line) - (size_t)(line_end - line),
" object>\n");
}
if (strncmp(line_data, "handle @ /", sizeof("handle @ /") - 1) == 0) {
char *start = line_data + sizeof("handle @ ") - 1;

View File

@@ -351,7 +351,7 @@ python_sudo_conversation(PyObject *Py_UNUSED(self), PyObject *py_args, PyObject
goto cleanup;
}
replies = calloc(num_msgs, sizeof(struct sudo_conv_reply));
replies = calloc((size_t)num_msgs, sizeof(struct sudo_conv_reply));
if (replies == NULL)
goto cleanup;
py_result = PyTuple_New(num_msgs);