From: Wayne Davison Date: Tue, 25 Apr 2006 23:35:11 +0000 (+0000) Subject: Make sure that ida_list_free() doesn't call free() on a NULL pointer. X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/commitdiff_plain/c1471566d1bd80fa79a2dae5f1785fe10040882b Make sure that ida_list_free() doesn't call free() on a NULL pointer. --- diff --git a/acls.diff b/acls.diff index be2e799..7e1934e 100644 --- a/acls.diff +++ b/acls.diff @@ -38,7 +38,7 @@ TODO items: popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \ --- old/acls.c +++ new/acls.c -@@ -0,0 +1,1305 @@ +@@ -0,0 +1,1307 @@ +/* -*- c-file-style: "linux" -*- + Copyright (C) Andrew Tridgell 1996 + Copyright (C) Paul Mackerras 1996 @@ -164,10 +164,12 @@ TODO items: + +static void ida_list_free(ida_list *idal) +{ -+ free(idal->idas); -+ idal->idas = NULL; -+ idal->count = 0; -+ idal->malloced = 0; ++ if (idal->idas) { ++ free(idal->idas); ++ idal->idas = NULL; ++ idal->count = 0; ++ idal->malloced = 0; ++ } +} + +static void rsync_acl_free(rsync_acl *racl) @@ -1346,7 +1348,7 @@ TODO items: +#endif /* SUPPORT_ACLS */ --- old/backup.c +++ new/backup.c -@@ -28,6 +28,7 @@ extern char *backup_suffix; +@@ -29,6 +29,7 @@ extern char *backup_suffix; extern char *backup_dir; extern int am_root; @@ -1354,7 +1356,7 @@ TODO items: extern int preserve_devices; extern int preserve_specials; extern int preserve_links; -@@ -132,6 +133,10 @@ static int make_bak_dir(char *fullpath) +@@ -133,6 +134,10 @@ static int make_bak_dir(char *fullpath) } else { do_lchown(fullpath, st.st_uid, st.st_gid); do_chmod(fullpath, st.st_mode); @@ -1365,7 +1367,7 @@ TODO items: } } *p = '/'; -@@ -185,6 +190,11 @@ static int keep_backup(char *fname) +@@ -186,6 +191,11 @@ static int keep_backup(char *fname) if (!(buf = get_backup_name(fname))) return 0; @@ -1377,7 +1379,7 @@ TODO items: /* Check to see if this is a device file, or link */ if ((am_root && preserve_devices && IS_DEVICE(file->mode)) || (preserve_specials && IS_SPECIAL(file->mode))) { -@@ -260,6 +270,10 @@ static int keep_backup(char *fname) +@@ -261,6 +271,10 @@ static int keep_backup(char *fname) } } set_file_attrs(buf, file, NULL, 0); @@ -1483,7 +1485,7 @@ TODO items: --- old/flist.c +++ new/flist.c -@@ -44,6 +44,7 @@ extern int filesfrom_fd; +@@ -40,6 +40,7 @@ extern int filesfrom_fd; extern int one_file_system; extern int copy_dirlinks; extern int keep_dirlinks; @@ -1491,7 +1493,7 @@ TODO items: extern int preserve_links; extern int preserve_hard_links; extern int preserve_devices; -@@ -965,6 +966,11 @@ static struct file_struct *send_file_nam +@@ -961,6 +962,11 @@ static struct file_struct *send_file_nam if (chmod_modes && !S_ISLNK(file->mode)) file->mode = tweak_mode(file->mode, chmod_modes); @@ -1503,7 +1505,7 @@ TODO items: maybe_emit_filelist_progress(flist->count + flist_count_offset); flist_expand(flist); -@@ -972,6 +978,16 @@ static struct file_struct *send_file_nam +@@ -968,6 +974,16 @@ static struct file_struct *send_file_nam if (file->basename[0]) { flist->files[flist->count++] = file; send_file_entry(file, f); @@ -1520,7 +1522,7 @@ TODO items: } return file; } -@@ -1360,6 +1376,11 @@ struct file_list *recv_file_list(int f) +@@ -1356,6 +1372,11 @@ struct file_list *recv_file_list(int f) flags |= read_byte(f) << 8; file = receive_file_entry(flist, flags, f); @@ -1532,7 +1534,7 @@ TODO items: if (S_ISREG(file->mode) || S_ISLNK(file->mode)) stats.total_size += file->length; -@@ -1382,6 +1403,11 @@ struct file_list *recv_file_list(int f) +@@ -1378,6 +1399,11 @@ struct file_list *recv_file_list(int f) clean_flist(flist, relative_paths, 1); @@ -4896,7 +4898,7 @@ TODO items: --- old/options.c +++ new/options.c -@@ -45,6 +45,7 @@ int copy_dirlinks = 0; +@@ -47,6 +47,7 @@ int copy_dirlinks = 0; int copy_links = 0; int preserve_links = 0; int preserve_hard_links = 0; @@ -4904,7 +4906,7 @@ TODO items: int preserve_perms = 0; int preserve_executability = 0; int preserve_devices = 0; -@@ -192,6 +193,7 @@ static void print_rsync_version(enum log +@@ -194,6 +195,7 @@ static void print_rsync_version(enum log char const *got_socketpair = "no "; char const *have_inplace = "no "; char const *hardlinks = "no "; @@ -4912,7 +4914,7 @@ TODO items: char const *links = "no "; char const *ipv6 = "no "; STRUCT_STAT *dumstat; -@@ -208,6 +210,10 @@ static void print_rsync_version(enum log +@@ -210,6 +212,10 @@ static void print_rsync_version(enum log hardlinks = ""; #endif @@ -4923,7 +4925,7 @@ TODO items: #ifdef SUPPORT_LINKS links = ""; #endif -@@ -221,9 +227,9 @@ static void print_rsync_version(enum log +@@ -223,9 +229,9 @@ static void print_rsync_version(enum log rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); rprintf(f, "\n"); rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, " @@ -4935,7 +4937,7 @@ TODO items: /* Note that this field may not have type ino_t. It depends * on the complicated interaction between largefile feature -@@ -293,6 +299,9 @@ void usage(enum logcode F) +@@ -295,6 +301,9 @@ void usage(enum logcode F) rprintf(F," -H, --hard-links preserve hard links\n"); rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); @@ -4945,7 +4947,7 @@ TODO items: rprintf(F," --chmod=CHMOD change destination permissions\n"); rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); -@@ -408,6 +417,9 @@ static struct poptOption long_options[] +@@ -410,6 +419,9 @@ static struct poptOption long_options[] {"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 }, @@ -4955,7 +4957,7 @@ TODO items: {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, -@@ -1066,6 +1078,24 @@ int parse_arguments(int *argc, const cha +@@ -1068,6 +1080,24 @@ int parse_arguments(int *argc, const cha usage(FINFO); exit_cleanup(0); @@ -4980,7 +4982,7 @@ TODO items: default: /* A large opt value means that set_refuse_options() * turned this option off. */ -@@ -1508,6 +1538,10 @@ void server_options(char **args,int *arg +@@ -1510,6 +1540,10 @@ void server_options(char **args,int *arg if (preserve_hard_links) argstr[x++] = 'H'; @@ -4993,7 +4995,7 @@ TODO items: if (preserve_gid) --- old/receiver.c +++ new/receiver.c -@@ -46,6 +46,7 @@ extern int keep_partial; +@@ -48,6 +48,7 @@ extern int keep_partial; extern int checksum_seed; extern int inplace; extern int delay_updates; @@ -5001,7 +5003,7 @@ TODO items: extern struct stats stats; extern char *log_format; extern char *tmpdir; -@@ -344,6 +345,10 @@ int recv_files(int f_in, struct file_lis +@@ -346,6 +347,10 @@ int recv_files(int f_in, struct file_lis int itemizing = am_daemon ? daemon_log_format_has_i : !am_server && log_format_has_i; int max_phase = protocol_version >= 29 ? 2 : 1; @@ -5012,7 +5014,7 @@ TODO items: int i, recv_ok; if (verbose > 2) -@@ -541,7 +546,16 @@ int recv_files(int f_in, struct file_lis +@@ -543,7 +548,16 @@ int recv_files(int f_in, struct file_lis * mode based on the local permissions and some heuristics. */ if (!preserve_perms) { int exists = fd1 != -1; @@ -5543,7 +5545,7 @@ TODO items: +exit 0 --- old/uidlist.c +++ new/uidlist.c -@@ -34,6 +34,7 @@ +@@ -35,6 +35,7 @@ extern int verbose; extern int preserve_uid; extern int preserve_gid; @@ -5551,7 +5553,7 @@ TODO items: extern int numeric_ids; extern int am_root; -@@ -274,7 +275,7 @@ void send_uid_list(int f) +@@ -275,7 +276,7 @@ void send_uid_list(int f) if (numeric_ids) return; @@ -5560,7 +5562,7 @@ TODO items: int len; /* we send sequences of uid/byte-length/name */ for (list = uidlist; list; list = list->next) { -@@ -291,7 +292,7 @@ void send_uid_list(int f) +@@ -292,7 +293,7 @@ void send_uid_list(int f) write_int(f, 0); } @@ -5569,7 +5571,7 @@ TODO items: int len; for (list = gidlist; list; list = list->next) { if (!list->name) -@@ -312,7 +313,7 @@ void recv_uid_list(int f, struct file_li +@@ -313,7 +314,7 @@ void recv_uid_list(int f, struct file_li int id, i; char *name; @@ -5578,7 +5580,7 @@ TODO items: /* read the uid list */ while ((id = read_int(f)) != 0) { int len = read_byte(f); -@@ -324,7 +325,7 @@ void recv_uid_list(int f, struct file_li +@@ -325,7 +326,7 @@ void recv_uid_list(int f, struct file_li } } @@ -5587,7 +5589,7 @@ TODO items: /* read the gid list */ while ((id = read_int(f)) != 0) { int len = read_byte(f); -@@ -336,6 +337,16 @@ void recv_uid_list(int f, struct file_li +@@ -337,6 +338,16 @@ void recv_uid_list(int f, struct file_li } }