Merge pull request #278 from AtariDreams/types
Avoid compiler casting warnings Part 2
This commit is contained in:
@@ -90,7 +90,7 @@ mktemp_internal(int dfd, char *path, int slen, int mode, int flags)
|
|||||||
cp = start;
|
cp = start;
|
||||||
do {
|
do {
|
||||||
unsigned short rbuf[16];
|
unsigned short rbuf[16];
|
||||||
unsigned int i;
|
size_t i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Avoid lots of arc4random() calls by using
|
* Avoid lots of arc4random() calls by using
|
||||||
|
@@ -201,5 +201,5 @@ main(int argc, char *argv[])
|
|||||||
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
|
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(errors);
|
return errors;
|
||||||
}
|
}
|
||||||
|
@@ -304,7 +304,8 @@ sudo_debug_register_v2(const char *program, const char *const subsystems[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (instance == NULL) {
|
if (instance == NULL) {
|
||||||
unsigned int i, j, max_id = NUM_DEF_SUBSYSTEMS - 1;
|
size_t i;
|
||||||
|
unsigned int j, max_id = NUM_DEF_SUBSYSTEMS - 1;
|
||||||
|
|
||||||
/* Fill in subsystem name -> id mapping as needed. */
|
/* Fill in subsystem name -> id mapping as needed. */
|
||||||
if (ids != NULL) {
|
if (ids != NULL) {
|
||||||
@@ -348,7 +349,7 @@ sudo_debug_register_v2(const char *program, const char *const subsystems[],
|
|||||||
} else {
|
} else {
|
||||||
/* Check for matching instance but different ids[]. */
|
/* Check for matching instance but different ids[]. */
|
||||||
if (ids != NULL && instance->subsystem_ids != ids) {
|
if (ids != NULL && instance->subsystem_ids != ids) {
|
||||||
unsigned int i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; subsystems[i] != NULL; i++)
|
for (i = 0; subsystems[i] != NULL; i++)
|
||||||
ids[i] = instance->subsystem_ids[i];
|
ids[i] = instance->subsystem_ids[i];
|
||||||
|
@@ -121,7 +121,7 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, char *name, size_t namelen)
|
|||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
unsigned int i;
|
size_t i;
|
||||||
DIR *d = NULL;
|
DIR *d = NULL;
|
||||||
debug_decl(sudo_ttyname_scan, SUDO_DEBUG_UTIL);
|
debug_decl(sudo_ttyname_scan, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
|
@@ -200,7 +200,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (group_plugin_load(plugin) != 1) {
|
if (group_plugin_load(plugin) != 1) {
|
||||||
fprintf(stderr, "unable to load plugin: %s\n", plugin);
|
fprintf(stderr, "unable to load plugin: %s\n", plugin);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; argv[i] != NULL; i++) {
|
for (i = 0; argv[i] != NULL; i++) {
|
||||||
@@ -215,6 +215,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
group_plugin_unload();
|
group_plugin_unload();
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -225,7 +225,7 @@ find_editor(int nfiles, char * const *files, int *argc_out, char ***argv_out,
|
|||||||
{
|
{
|
||||||
char *editor_path = NULL;
|
char *editor_path = NULL;
|
||||||
const char *ev[3];
|
const char *ev[3];
|
||||||
unsigned int i;
|
size_t i;
|
||||||
debug_decl(find_editor, SUDOERS_DEBUG_UTIL);
|
debug_decl(find_editor, SUDOERS_DEBUG_UTIL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -48,18 +48,13 @@ sudo_filedigest(int fd, const char *file, unsigned int digest_type,
|
|||||||
*digest_len = sudo_digest_getlen(digest_type);
|
*digest_len = sudo_digest_getlen(digest_type);
|
||||||
if (*digest_len == (size_t)-1) {
|
if (*digest_len == (size_t)-1) {
|
||||||
sudo_warnx(U_("unsupported digest type %u for %s"), digest_type, file);
|
sudo_warnx(U_("unsupported digest type %u for %s"), digest_type, file);
|
||||||
goto bad;
|
debug_return_ptr(NULL);
|
||||||
}
|
|
||||||
|
|
||||||
if ((dig = sudo_digest_alloc(digest_type)) == NULL) {
|
|
||||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
|
||||||
goto bad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd2 = dup(fd)) == -1) {
|
if ((fd2 = dup(fd)) == -1) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "unable to dup %s: %s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "unable to dup %s: %s",
|
||||||
file, strerror(errno));
|
file, strerror(errno));
|
||||||
goto bad;
|
debug_return_ptr(NULL);
|
||||||
}
|
}
|
||||||
if ((fp = fdopen(fd2, "r")) == NULL) {
|
if ((fp = fdopen(fd2, "r")) == NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "unable to fdopen %s: %s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "unable to fdopen %s: %s",
|
||||||
@@ -71,7 +66,10 @@ sudo_filedigest(int fd, const char *file, unsigned int digest_type,
|
|||||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
if ((dig = sudo_digest_alloc(digest_type)) == NULL) {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
while ((nread = fread(buf, 1, sizeof(buf), fp)) != 0) {
|
while ((nread = fread(buf, 1, sizeof(buf), fp)) != 0) {
|
||||||
sudo_digest_update(dig, buf, nread);
|
sudo_digest_update(dig, buf, nread);
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ addr_matches_if(const char *n)
|
|||||||
union sudo_in_addr_un addr;
|
union sudo_in_addr_un addr;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
#ifdef HAVE_STRUCT_IN6_ADDR
|
#ifdef HAVE_STRUCT_IN6_ADDR
|
||||||
unsigned int j;
|
size_t j;
|
||||||
#endif
|
#endif
|
||||||
unsigned int family;
|
unsigned int family;
|
||||||
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH);
|
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH);
|
||||||
@@ -98,11 +98,11 @@ addr_matches_if(const char *n)
|
|||||||
static bool
|
static bool
|
||||||
addr_matches_if_netmask(const char *n, const char *m)
|
addr_matches_if_netmask(const char *n, const char *m)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
size_t i;
|
||||||
union sudo_in_addr_un addr, mask;
|
union sudo_in_addr_un addr, mask;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
#ifdef HAVE_STRUCT_IN6_ADDR
|
#ifdef HAVE_STRUCT_IN6_ADDR
|
||||||
unsigned int j;
|
size_t j;
|
||||||
#endif
|
#endif
|
||||||
unsigned int family;
|
unsigned int family;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
@@ -84,9 +84,9 @@ digest_matches(int fd, const char *path,
|
|||||||
}
|
}
|
||||||
if (strlen(digest->digest_str) == digest_len * 2) {
|
if (strlen(digest->digest_str) == digest_len * 2) {
|
||||||
/* Convert ascii hex to binary. */
|
/* Convert ascii hex to binary. */
|
||||||
unsigned int i;
|
size_t i;
|
||||||
for (i = 0; i < digest_len; i++) {
|
for (i = 0; i < digest_len; i++) {
|
||||||
const int h = sudo_hexchar(&digest->digest_str[i + i]);
|
const int h = sudo_hexchar(&digest->digest_str[2 * i]);
|
||||||
if (h == -1)
|
if (h == -1)
|
||||||
goto bad_format;
|
goto bad_format;
|
||||||
sudoers_digest[i] = (unsigned char)h;
|
sudoers_digest[i] = (unsigned char)h;
|
||||||
|
@@ -38,7 +38,7 @@ main(int argc, char *argv[])
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if ((fp = fopen(argv[1], "r")) == NULL) {
|
if ((fp = fopen(argv[1], "r")) == NULL) {
|
||||||
perror(argv[1]);
|
perror(argv[1]);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,5 +72,5 @@ main(int argc, char *argv[])
|
|||||||
getprogname(), tests, tests == 1 ? "" : "s", errors,
|
getprogname(), tests, tests == 1 ? "" : "s", errors,
|
||||||
(tests - errors) * 100 / tests);
|
(tests - errors) * 100 / tests);
|
||||||
}
|
}
|
||||||
exit(errors);
|
return errors;
|
||||||
}
|
}
|
||||||
|
@@ -101,5 +101,5 @@ main(int argc, char *argv[])
|
|||||||
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
|
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(errors);
|
return errors;
|
||||||
}
|
}
|
||||||
|
@@ -225,7 +225,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Read sudo.conf and initialize the debug subsystem. */
|
/* Read sudo.conf and initialize the debug subsystem. */
|
||||||
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
sudo_debug_register(getprogname(), NULL, NULL,
|
sudo_debug_register(getprogname(), NULL, NULL,
|
||||||
sudo_conf_debug_files(getprogname()), -1);
|
sudo_conf_debug_files(getprogname()), -1);
|
||||||
|
|
||||||
@@ -1479,7 +1479,7 @@ find_sessions(const char *dir, regex_t *re, const char *user, const char *tty)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct sudo_lbuf lbuf;
|
struct sudo_lbuf lbuf;
|
||||||
size_t sdlen, sessions_len = 0, sessions_size = 0;
|
size_t sdlen, sessions_len = 0, sessions_size = 0;
|
||||||
unsigned int i;
|
size_t i;
|
||||||
int len;
|
int len;
|
||||||
char pathbuf[PATH_MAX], **sessions = NULL;
|
char pathbuf[PATH_MAX], **sessions = NULL;
|
||||||
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
|
@@ -392,7 +392,7 @@ done:
|
|||||||
sudo_freepwcache();
|
sudo_freepwcache();
|
||||||
sudo_freegrcache();
|
sudo_freegrcache();
|
||||||
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
|
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
|
||||||
exit(exitcode);
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -81,7 +81,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Initialize the debug subsystem. */
|
/* Initialize the debug subsystem. */
|
||||||
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname()));
|
sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname()));
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "f:u:")) != -1) {
|
while ((ch = getopt(argc, argv, "f:u:")) != -1) {
|
||||||
|
@@ -167,11 +167,11 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Read debug and plugin sections of sudo.conf. */
|
/* Read debug and plugin sections of sudo.conf. */
|
||||||
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS) == -1)
|
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS) == -1)
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
/* Initialize the debug subsystem. */
|
/* Initialize the debug subsystem. */
|
||||||
if (!sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())))
|
if (!sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())))
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
/* Parse sudoers plugin options, if any. */
|
/* Parse sudoers plugin options, if any. */
|
||||||
parse_sudoers_options();
|
parse_sudoers_options();
|
||||||
@@ -294,7 +294,7 @@ main(int argc, char *argv[])
|
|||||||
sudoers_conf.sudoers_path = path_sudoers;
|
sudoers_conf.sudoers_path = path_sudoers;
|
||||||
init_parser(NULL, &sudoers_conf);
|
init_parser(NULL, &sudoers_conf);
|
||||||
if ((sudoersin = open_sudoers(path_sudoers, &sudoers, true, NULL)) == NULL)
|
if ((sudoersin = open_sudoers(path_sudoers, &sudoers, true, NULL)) == NULL)
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
|
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
|
||||||
(void) sudoersparse();
|
(void) sudoersparse();
|
||||||
(void) update_defaults(&parsed_policy, NULL,
|
(void) update_defaults(&parsed_policy, NULL,
|
||||||
|
@@ -321,7 +321,7 @@ mon_backchannel_cb(int fd, int what, void *v)
|
|||||||
* Note that the backchannel is a *blocking* socket.
|
* Note that the backchannel is a *blocking* socket.
|
||||||
*/
|
*/
|
||||||
n = recv(fd, &cstmp, sizeof(cstmp), MSG_WAITALL);
|
n = recv(fd, &cstmp, sizeof(cstmp), MSG_WAITALL);
|
||||||
if (n != sizeof(cstmp)) {
|
if (n != ssizeof(cstmp)) {
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
if (errno == EINTR || errno == EAGAIN)
|
||||||
debug_return;
|
debug_return;
|
||||||
|
10
src/limits.c
10
src/limits.c
@@ -671,11 +671,11 @@ set_policy_rlimits(void)
|
|||||||
debug_return;
|
debug_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
size_t
|
||||||
serialize_rlimits(char **info, unsigned int info_max)
|
serialize_rlimits(char **info, size_t info_max)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
unsigned int idx, nstored = 0;
|
size_t idx, nstored = 0;
|
||||||
debug_decl(serialize_rlimits, SUDO_DEBUG_UTIL);
|
debug_decl(serialize_rlimits, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
for (idx = 0; idx < nitems(saved_limits); idx++) {
|
for (idx = 0; idx < nitems(saved_limits); idx++) {
|
||||||
@@ -706,9 +706,9 @@ serialize_rlimits(char **info, unsigned int info_max)
|
|||||||
goto oom;
|
goto oom;
|
||||||
info[nstored++] = str;
|
info[nstored++] = str;
|
||||||
}
|
}
|
||||||
debug_return_int(nstored);
|
debug_return_size_t(nstored);
|
||||||
oom:
|
oom:
|
||||||
while (nstored)
|
while (nstored)
|
||||||
free(info[--nstored]);
|
free(info[--nstored]);
|
||||||
debug_return_int(-1);
|
debug_return_size_t(-1);
|
||||||
}
|
}
|
||||||
|
@@ -157,7 +157,7 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
|
|
||||||
/* Read sudo.conf and initialize the debug subsystem. */
|
/* Read sudo.conf and initialize the debug subsystem. */
|
||||||
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
sudo_debug_register(getprogname(), NULL, NULL,
|
sudo_debug_register(getprogname(), NULL, NULL,
|
||||||
sudo_conf_debug_files(getprogname()), -1);
|
sudo_conf_debug_files(getprogname()), -1);
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
if (rundir != NULL && chdir(rundir) == -1) {
|
if (rundir != NULL && chdir(rundir) == -1) {
|
||||||
sudo_warnx(U_("unable to change directory to %s"), rundir);
|
sudo_warnx(U_("unable to change directory to %s"), rundir);
|
||||||
if (!ISSET(flags, CD_CWD_OPTIONAL))
|
if (!ISSET(flags, CD_CWD_OPTIONAL))
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a copy of the command to execute. */
|
/* Make a copy of the command to execute. */
|
||||||
|
@@ -500,11 +500,11 @@ static char **
|
|||||||
get_user_info(struct user_details *ud)
|
get_user_info(struct user_details *ud)
|
||||||
{
|
{
|
||||||
char *cp, **info, path[PATH_MAX];
|
char *cp, **info, path[PATH_MAX];
|
||||||
unsigned int info_max = 32 + RLIM_NLIMITS;
|
size_t info_max = 32 + RLIM_NLIMITS;
|
||||||
unsigned int i = 0;
|
size_t i = 0, n;
|
||||||
mode_t mask;
|
mode_t mask;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int ttyfd, n;
|
int ttyfd;
|
||||||
debug_decl(get_user_info, SUDO_DEBUG_UTIL);
|
debug_decl(get_user_info, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -629,7 +629,7 @@ get_user_info(struct user_details *ud)
|
|||||||
goto oom;
|
goto oom;
|
||||||
|
|
||||||
n = serialize_rlimits(&info[i + 1], info_max - (i + 1));
|
n = serialize_rlimits(&info[i + 1], info_max - (i + 1));
|
||||||
if (n == -1)
|
if (n == (size_t)-1)
|
||||||
goto oom;
|
goto oom;
|
||||||
i += n;
|
i += n;
|
||||||
|
|
||||||
|
@@ -343,7 +343,7 @@ void restore_nproc(void);
|
|||||||
void set_policy_rlimits(void);
|
void set_policy_rlimits(void);
|
||||||
void unlimit_nproc(void);
|
void unlimit_nproc(void);
|
||||||
void unlimit_sudo(void);
|
void unlimit_sudo(void);
|
||||||
int serialize_rlimits(char **info, unsigned int info_max);
|
size_t serialize_rlimits(char **info, size_t info_max);
|
||||||
bool parse_policy_rlimit(const char *str);
|
bool parse_policy_rlimit(const char *str);
|
||||||
|
|
||||||
/* exec_ptrace.c */
|
/* exec_ptrace.c */
|
||||||
|
@@ -71,7 +71,7 @@ set_tmpdir(const struct sudo_cred *user_cred)
|
|||||||
_PATH_TMP
|
_PATH_TMP
|
||||||
};
|
};
|
||||||
struct sudo_cred saved_cred;
|
struct sudo_cred saved_cred;
|
||||||
unsigned int i;
|
size_t i;
|
||||||
size_t len;
|
size_t len;
|
||||||
int dfd;
|
int dfd;
|
||||||
debug_decl(set_tmpdir, SUDO_DEBUG_EDIT);
|
debug_decl(set_tmpdir, SUDO_DEBUG_EDIT);
|
||||||
|
Reference in New Issue
Block a user