summaryrefslogtreecommitdiffstats
path: root/source3/modules
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-04-08 17:34:16 +0000
committerSimo Sorce <idra@samba.org>2003-04-08 17:34:16 +0000
commit90290b166b70dc2606d076f3266b6a9353a49c61 (patch)
tree6a6ee7063038cf259112c5ed9549bf07f3eb060d /source3/modules
parenta87d3b2cba01f0d0417de0b7a1070872741b2762 (diff)
downloadsamba-90290b166b70dc2606d076f3266b6a9353a49c61.tar.gz
samba-90290b166b70dc2606d076f3266b6a9353a49c61.tar.xz
samba-90290b166b70dc2606d076f3266b6a9353a49c61.zip
reworked to not malloc PATH_MAX long strings
corrected path_name creation (This used to be commit f4be4e70a12edae83b9b89622ca5077a7d3d5602)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_recycle.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index 18056fe796..d554f4bfdd 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -519,15 +519,16 @@ static int recycle_unlink(connection_struct *conn, const char *file_name)
*/
/* extract filename and path */
- path_name = (char *)malloc(PATH_MAX);
- ALLOC_CHECK(path_name, done);
- safe_strcpy(path_name, file_name, PATH_MAX - 1);
- base = strrchr(path_name, '/');
+ base = strrchr(file_name, '/');
if (base == NULL) {
base = file_name;
- safe_strcpy(path_name, "/", PATH_MAX - 1);
+ path_name = strdup("/");
+ ALLOC_CHECK(path_name, done);
}
else {
+ path_name = strdup(file_name);
+ ALLOC_CHECK(path_name, done);
+ path_name[base - file_name] = '\0';
base++;
}
@@ -551,14 +552,13 @@ static int recycle_unlink(connection_struct *conn, const char *file_name)
goto done;
}
- temp_name = (char *)malloc(PATH_MAX);
- ALLOC_CHECK(temp_name, done);
- safe_strcpy(temp_name, recbin->repository, PATH_MAX - 1);
-
/* see if we need to recreate the original directory structure in the recycle bin */
if (recbin->keep_dir_tree == True) {
- safe_strcat(temp_name, "/", PATH_MAX - 1);
- safe_strcat(temp_name, path_name, PATH_MAX - 1);
+ asprintf(&temp_name, "%s/%s", recbin->repository, path_name);
+ ALLOC_CHECK(temp_name, done);
+ } else {
+ temp_name = strdup(recbin->repository);
+ ALLOC_CHECK(temp_name, done);
}
exist = recycle_directory_exist(conn, temp_name);