lib/tcbfuncs.c: rmdir_leading(): Constify input

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2024-11-16 18:16:40 +01:00 committed by Serge Hallyn
parent e7771cc196
commit 4cf430b309

View File

@ -254,17 +254,23 @@ static shadowtcb_status unlink_suffs (const char *user)
}
/* path should be a relative existing tcb directory */
static shadowtcb_status rmdir_leading (char *path)
static shadowtcb_status
rmdir_leading(const char *relpath)
{
char *ind, *dir;
char *ind, *dir, *path;
shadowtcb_status ret = SHADOWTCB_SUCCESS;
path = strdup(relpath);
if (path == NULL)
goto oom;
while ((ind = strrchr (path, '/'))) {
stpcpy(ind, "");
dir = aprintf(TCB_DIR "/%s", path);
if (dir == NULL) {
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
if (dir == NULL)
goto free_path;
if (rmdir (dir) != 0) {
if (errno != ENOTEMPTY) {
fprintf (shadow_logfd,
@ -277,7 +283,15 @@ static shadowtcb_status rmdir_leading (char *path)
}
free (dir);
}
free(path);
return ret;
free_path:
free(path);
oom:
OUT_OF_MEMORY;
return SHADOWTCB_FAILURE;
}
static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)