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

Make size related variables and outputs size_t #539

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions acls.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static void send_ida_entries(int f, const ida_entries *idal)
name = numeric_ids ? NULL : add_gid(ida->id);
write_varint(f, ida->id);
if (inc_recurse && name) {
int len = strlen(name);
size_t len = strlen(name);
write_varint(f, xbits | XFLAG_NAME_FOLLOWS);
write_byte(f, len);
write_buf(f, name, len);
Expand Down Expand Up @@ -730,7 +730,10 @@ static uchar recv_ida_entries(int f, ida_entries *ent)

static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type, mode_t mode)
{
#ifndef HAVE_OSX_ACLS
uchar computed_mask_bits = 0;
#endif

acl_duo *duo_item;
uchar flags;
int ndx = read_varint(f);
Expand Down Expand Up @@ -758,14 +761,15 @@ static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type, mode
duo_item->racl.mask_obj = recv_acl_access(f, NULL);
if (flags & XMIT_OTHER_OBJ)
duo_item->racl.other_obj = recv_acl_access(f, NULL);
if (flags & XMIT_NAME_LIST)
computed_mask_bits |= recv_ida_entries(f, &duo_item->racl.names);

#ifdef HAVE_OSX_ACLS
/* If we received a superfluous mask, throw it away. */
duo_item->racl.mask_obj = NO_ENTRY;
(void)mode;
#else
if (flags & XMIT_NAME_LIST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks like it will change the wire protocol if HAVE_OSX_ACLS is defined

computed_mask_bits |= recv_ida_entries(f, &duo_item->racl.names);

if (duo_item->racl.names.count && duo_item->racl.mask_obj == NO_ENTRY) {
/* Mask must be non-empty with lists. */
if (type == SMB_ACL_TYPE_ACCESS)
Expand Down
4 changes: 2 additions & 2 deletions authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static const char *check_secret(int module, const char *user, const char *group,
STRUCT_STAT st;
int ok = 1;
int user_len = strlen(user);
int group_len = group ? strlen(group) : 0;
size_t group_len = group ? strlen(group) : 0;
char *err;
FILE *fh;

Expand Down Expand Up @@ -140,7 +140,7 @@ static const char *check_secret(int module, const char *user, const char *group,
err = "secret not found";
while ((user || group) && fgets(line, sizeof line, fh) != NULL) {
const char **ptr, *s = strtok(line, "\n\r");
int len;
size_t len;
if (!s)
continue;
if (*s == '@') {
Expand Down
11 changes: 6 additions & 5 deletions batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void check_batch_flags(void)
static int write_arg(const char *arg)
{
const char *x, *s;
int len, err = 0;
size_t len;
int err = 0;

if (*arg == '-' && (x = strchr(arg, '=')) != NULL) {
err |= write(batch_sh_fd, arg, x - arg + 1) != x - arg + 1;
Expand All @@ -178,23 +179,23 @@ static int write_arg(const char *arg)
err |= write(batch_sh_fd, "'", 1) != 1;
}
len = strlen(s);
err |= write(batch_sh_fd, s, len) != len;
err |= write(batch_sh_fd, s, len) != (ssize_t)len;
err |= write(batch_sh_fd, "'", 1) != 1;
return err;
}

len = strlen(arg);
err |= write(batch_sh_fd, arg, len) != len;
err |= write(batch_sh_fd, arg, len) != (ssize_t)len;

return err;
}

/* Writes out a space and then an option (or other string) with an optional "=" + arg suffix. */
static int write_opt(const char *opt, const char *arg)
{
int len = strlen(opt);
size_t len = strlen(opt);
int err = write(batch_sh_fd, " ", 1) != 1;
err = write(batch_sh_fd, opt, len) != len ? 1 : 0;
err = write(batch_sh_fd, opt, len) != (ssize_t)len ? 1 : 0;
if (arg) {
err |= write(batch_sh_fd, "=", 1) != 1;
err |= write_arg(arg);
Expand Down
22 changes: 11 additions & 11 deletions clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ char *daemon_auth_choices;
int read_only = 0;
int module_id = -1;
int pid_file_fd = -1;
int early_input_len = 0;
size_t early_input_len = 0;
char *early_input = NULL;
pid_t namecvt_pid = 0;
struct chmod_mode_struct *daemon_chmod_modes;
Expand All @@ -83,7 +83,7 @@ struct chmod_mode_struct *daemon_chmod_modes;
* mode and module_dir is not "/"; otherwise 0. (Note that a chroot-
* enabled module can have a non-"/" module_dir these days.) */
char *module_dir = NULL;
unsigned int module_dirlen = 0;
size_t module_dirlen = 0;

char *full_module_path;

Expand Down Expand Up @@ -158,7 +158,7 @@ static int exchange_protocols(int f_in, int f_out, char *buf, size_t bufsiz, int
if (motd && *motd) {
FILE *f = fopen(motd, "r");
while (f && !feof(f)) {
int len = fread(buf, 1, bufsiz - 1, f);
size_t len = fread(buf, 1, bufsiz - 1, f);
if (len > 0)
write_buf(f_out, buf, len);
}
Expand Down Expand Up @@ -271,14 +271,14 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
return -1;
}
early_input_len = st.st_size;
if (early_input_len > (int)sizeof line) {
rprintf(FERROR, "%s is > %d bytes.\n", early_input_file, (int)sizeof line);
if (early_input_len > sizeof line) {
rprintf(FERROR, "%s is > %zu bytes.\n", early_input_file, sizeof line);
return -1;
}
if (early_input_len > 0) {
io_printf(f_out, EARLY_INPUT_CMD "%d\n", early_input_len);
io_printf(f_out, EARLY_INPUT_CMD "%zu\n", early_input_len);
while (early_input_len > 0) {
int len;
size_t len;
if (feof(f)) {
rprintf(FERROR, "Early EOF in %s\n", early_input_file);
return -1;
Expand Down Expand Up @@ -1158,7 +1158,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
if (!ret || err_msg) {
if (err_msg) {
while ((p = strchr(err_msg, '\n')) != NULL) {
int len = p - err_msg + 1;
size_t len = p - err_msg + 1;
rwrite(FERROR, err_msg, len, 0);
err_msg += len;
}
Expand Down Expand Up @@ -1355,8 +1355,8 @@ int start_daemon(int f_in, int f_out)
return -1;

if (strncmp(line, EARLY_INPUT_CMD, EARLY_INPUT_CMDLEN) == 0) {
early_input_len = strtol(line + EARLY_INPUT_CMDLEN, NULL, 10);
if (early_input_len <= 0 || early_input_len > BIGPATHBUFLEN) {
early_input_len = strtoul(line + EARLY_INPUT_CMDLEN, NULL, 10);
if (early_input_len == 0 || early_input_len > BIGPATHBUFLEN) {
io_printf(f_out, "@ERROR: invalid early_input length\n");
return -1;
}
Expand Down Expand Up @@ -1442,7 +1442,7 @@ static void create_pid_file(void)
pidbuf[len++] = '\n';
/* We don't need the buffer to end in a '\0' (and we may not have room to add it). */
#endif
if (write(pid_file_fd, pidbuf, len) != len)
if (len < 0 || write(pid_file_fd, pidbuf, len) != len)
fail = "write";
cleanup_set_pid(pid); /* Mark the file for removal on exit, even if the write failed. */
}
Expand Down
4 changes: 2 additions & 2 deletions compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ void validate_choice_vs_env(int ntype, int num1, int num2)
* are removed otherwise the char is prefixed to the duplicate term and, if it
* is an opening paren/bracket/brace, the matching closing char is suffixed.
* "none" is removed on the client side unless dup_markup != '\0'. */
int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len, char dup_markup)
size_t get_default_nno_list(struct name_num_obj *nno, char *to_buf, size_t to_buf_len, char dup_markup)
{
struct name_num_item *nni;
int len = 0, cnt = 0;
size_t len = 0, cnt = 0;
char delim = '\0', post_delim;

switch (dup_markup) {
Expand Down
3 changes: 2 additions & 1 deletion delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
enum delret ret;
unsigned remainder;
void *save_filters;
int j, dlen;
int j;
size_t dlen;
char *p;

if (DEBUG_GTE(DEL, 3)) {
Expand Down
59 changes: 30 additions & 29 deletions exclude.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ extern int trust_sender_args;
extern int module_id;

extern char curr_dir[MAXPATHLEN];
extern unsigned int curr_dir_len;
extern unsigned int module_dirlen;
extern size_t curr_dir_len;
extern size_t module_dirlen;

filter_rule_list filter_list = { .debug_type = "" };
filter_rule_list cvs_filter_list = { .debug_type = " [global CVS]" };
Expand Down Expand Up @@ -75,8 +75,8 @@ static BOOL parent_dirscan = False;
* files. This makes it easier to save the appropriate values when we
* "push" down into each subdirectory. */
static filter_rule **mergelist_parents;
static int mergelist_cnt = 0;
static int mergelist_size = 0;
static size_t mergelist_cnt = 0;
static size_t mergelist_size = 0;

#define LOCAL_RULE 1
#define REMOTE_RULE 2
Expand Down Expand Up @@ -115,13 +115,13 @@ static uchar cur_elide_value = REMOTE_RULE;

static void teardown_mergelist(filter_rule *ex)
{
int j;
size_t j;

if (!ex->u.mergelist)
return;

if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] deactivating mergelist #%d%s\n",
rprintf(FINFO, "[%s] deactivating mergelist #%zu%s\n",
who_am_i(), mergelist_cnt - 1,
ex->u.mergelist->debug_type);
}
Expand Down Expand Up @@ -252,7 +252,7 @@ static void add_rule(filter_rule_list *listp, const char *pat, unsigned int pat_
if (rule->rflags & FILTRULE_PERDIR_MERGE) {
filter_rule_list *lp;
unsigned int len;
int i;
size_t i;

if ((cp = strrchr(rule->pattern, '/')) != NULL)
cp++;
Expand Down Expand Up @@ -288,7 +288,7 @@ static void add_rule(filter_rule_list *listp, const char *pat, unsigned int pat_
mergelist_parents = realloc_array(mergelist_parents, filter_rule *, mergelist_size);
}
if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] activating mergelist #%d%s\n",
rprintf(FINFO, "[%s] activating mergelist #%zu%s\n",
who_am_i(), mergelist_cnt, lp->debug_type);
}
mergelist_parents[mergelist_cnt++] = rule;
Expand Down Expand Up @@ -378,7 +378,8 @@ void free_implied_include_partial_string()
* that the receiver uses to validate the file list from the sender. */
void add_implied_include(const char *arg, int skip_daemon_module)
{
int arg_len, saw_wild = 0, saw_live_open_brkt = 0, backslash_cnt = 0;
size_t arg_len;
int saw_wild = 0, saw_live_open_brkt = 0, backslash_cnt = 0;
int slash_cnt = 0;
const char *cp;
char *p;
Expand Down Expand Up @@ -596,12 +597,12 @@ static void pop_filter_list(filter_rule_list *listp)
* value and will be updated with the length of the resulting name. We
* always return a name that is null terminated, even if the merge_file
* name was not. */
static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
unsigned int prefix_skip)
static char *parse_merge_name(const char *merge_file, size_t *len_ptr,
size_t prefix_skip)
{
static char buf[MAXPATHLEN];
char *fn, tmpbuf[MAXPATHLEN];
unsigned int fn_len;
size_t fn_len;

if (!parent_dirscan && *merge_file != '/') {
/* Return the name unchanged it doesn't have any slashes. */
Expand Down Expand Up @@ -654,9 +655,9 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
}

/* Sets the dirbuf and dirbuf_len values. */
void set_filter_dir(const char *dir, unsigned int dirlen)
void set_filter_dir(const char *dir, size_t dirlen)
{
unsigned int len;
size_t len;
if (*dir != '/') {
memcpy(dirbuf, curr_dir, curr_dir_len);
dirbuf[curr_dir_len] = '/';
Expand All @@ -683,18 +684,18 @@ void set_filter_dir(const char *dir, unsigned int dirlen)
* parent directory of the first transfer dir. If it does, we scan all the
* dirs from that point through the parent dir of the transfer dir looking
* for the per-dir merge-file in each one. */
static BOOL setup_merge_file(int mergelist_num, filter_rule *ex,
static BOOL setup_merge_file(size_t mergelist_num, filter_rule *ex,
filter_rule_list *lp)
{
char buf[MAXPATHLEN];
char *x, *y, *pat = ex->pattern;
unsigned int len;
size_t len;

if (!(x = parse_merge_name(pat, NULL, 0)) || *x != '/')
return 0;

if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] performing parent_dirscan for mergelist #%d%s\n",
rprintf(FINFO, "[%s] performing parent_dirscan for mergelist #%zi%s\n",
who_am_i(), mergelist_num, lp->debug_type);
}
y = strrchr(x, '/');
Expand Down Expand Up @@ -739,7 +740,7 @@ static BOOL setup_merge_file(int mergelist_num, filter_rule *ex,
}
parent_dirscan = False;
if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] completed parent_dirscan for mergelist #%d%s\n",
rprintf(FINFO, "[%s] completed parent_dirscan for mergelist #%zu%s\n",
who_am_i(), mergelist_num, lp->debug_type);
}
free(pat);
Expand All @@ -755,10 +756,10 @@ struct local_filter_state {
* handle all the per-dir merge-files. The "dir" value is the current path
* relative to curr_dir (which might not be null-terminated). We copy it
* into dirbuf so that we can easily append a file name on the end. */
void *push_local_filters(const char *dir, unsigned int dirlen)
void *push_local_filters(const char *dir, size_t dirlen)
{
struct local_filter_state *push;
int i;
size_t i;

set_filter_dir(dir, dirlen);
if (DEBUG_GTE(FILTER, 2)) {
Expand Down Expand Up @@ -793,7 +794,7 @@ void *push_local_filters(const char *dir, unsigned int dirlen)
lp = ex->u.mergelist;

if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] pushing mergelist #%d%s\n",
rprintf(FINFO, "[%s] pushing mergelist #%zu%s\n",
who_am_i(), i, lp->debug_type);
}

Expand Down Expand Up @@ -871,7 +872,7 @@ void pop_local_filters(void *mem)
free(pop);
}

void change_local_filter_dir(const char *dname, int dlen, int dir_depth)
void change_local_filter_dir(const char *dname, size_t dlen, int dir_depth)
{
static int cur_depth = -1;
static void *filt_array[MAXPATHLEN/2+1];
Expand Down Expand Up @@ -968,8 +969,8 @@ static int rule_matches(const char *fname, filter_rule *ex, int name_flags)
if (strcmp(name, pattern) == 0)
return ret_match;
} else {
int l1 = strlen(name);
int l2 = strlen(pattern);
size_t l1 = strlen(name);
size_t l2 = strlen(pattern);
if (l2 <= l1 &&
strcmp(name+(l1-l2),pattern) == 0 &&
(l1==l2 || name[l1-(l2+1)] == '/')) {
Expand Down Expand Up @@ -1090,11 +1091,11 @@ static const uchar *rule_strcmp(const uchar *str, const char *rule, int rule_len
* template rflags and the xflags additionally affect parsing. */
static filter_rule *parse_rule_tok(const char **rulestr_ptr,
const filter_rule *template, int xflags,
const char **pat_ptr, unsigned int *pat_len_ptr)
const char **pat_ptr, size_t *pat_len_ptr)
{
const uchar *s = (const uchar *)*rulestr_ptr;
filter_rule *rule;
unsigned int len;
size_t len;

if (template->rflags & FILTRULE_WORD_SPLIT) {
/* Skip over any initial whitespace. */
Expand Down Expand Up @@ -1368,7 +1369,7 @@ void parse_filter_str(filter_rule_list *listp, const char *rulestr,
{
filter_rule *rule;
const char *pat;
unsigned int pat_len;
size_t pat_len;

if (!rulestr)
return;
Expand Down Expand Up @@ -1418,7 +1419,7 @@ void parse_filter_str(filter_rule_list *listp, const char *rulestr,
if (new_rflags & FILTRULE_PERDIR_MERGE) {
if (parent_dirscan) {
const char *p;
unsigned int len = pat_len;
size_t len = pat_len;
if ((p = parse_merge_name(pat, &len, module_dirlen)))
add_rule(listp, p, len, rule, 0);
else
Expand All @@ -1427,7 +1428,7 @@ void parse_filter_str(filter_rule_list *listp, const char *rulestr,
}
} else {
const char *p;
unsigned int len = pat_len;
size_t len = pat_len;
if ((p = parse_merge_name(pat, &len, 0)))
parse_filter_file(listp, p, rule, XFLG_FATAL_ERRORS);
free_filter(rule);
Expand Down
Loading