Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
1b8e662a
Commit
1b8e662a
authored
Nov 03, 1998
by
David Dykstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call clean_fname() in sanitize_path() to catch some more strange but
legal file name syntaxes.
parent
2acf81eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
46 deletions
+49
-46
util.c
util.c
+49
-46
No files found.
util.c
View file @
1b8e662a
...
...
@@ -579,6 +579,55 @@ void clean_fname(char *name)
}
}
/*
* Make path appear as if a chroot had occurred:
* 0. call clean_fname on it.
* 1. remove leading "/" (or replace with "." if at end)
* 2. remove leading ".." components
* 3. delete any other "<dir>/.." (recursively)
* Return a malloc'ed copy.
* Contributed by Dave Dykstra <dwd@bell-labs.com>
*/
char
*
sanitize_path
(
char
*
p
)
{
char
*
copy
,
*
copyp
;
clean_fname
(
p
);
copy
=
(
char
*
)
malloc
(
strlen
(
p
)
+
1
);
copyp
=
copy
;
while
(
*
p
!=
'\0'
)
{
if
((
*
p
==
'/'
)
&&
(
copyp
==
copy
))
{
/* remove leading slash */
p
++
;
}
else
if
((
*
p
==
'.'
)
&&
(
*
(
p
+
1
)
==
'.'
)
&&
((
*
(
p
+
2
)
==
'/'
)
||
(
*
(
p
+
2
)
==
'\0'
)))
{
/* remove .. followed by slash or end */
p
+=
2
;
if
(
copyp
!=
copy
)
{
/* backup the copy one level */
while
((
--
copyp
!=
copy
)
&&
(
*
copyp
==
'/'
))
/* skip trailing slashes */
;
while
((
copyp
!=
copy
)
&&
(
*
copyp
!=
'/'
))
/* skip back through slash */
copyp
--
;
}
}
else
{
/* copy one component */
while
(
1
)
{
*
copyp
++
=
*
p
++
;
if
((
*
p
==
'\0'
)
||
(
*
(
p
-
1
)
==
'/'
))
break
;
}
}
}
*
copyp
=
'\0'
;
return
(
copy
);
}
static
char
curr_dir
[
MAXPATHLEN
];
...
...
@@ -716,52 +765,6 @@ int unsafe_symlink(char *dest, char *src)
return
(
depth
<
0
);
}
/*
* Make path appear as if a chroot had occurred:
* 1. remove leading "/" (or replace with "." if at end)
* 2. remove leading ".." components
* 3. delete any other "<dir>/.." (recursively)
* Return a malloc'ed copy.
* Contributed by Dave Dykstra <dwd@bell-labs.com>
*/
char
*
sanitize_path
(
char
*
p
)
{
char
*
copy
,
*
copyp
;
copy
=
(
char
*
)
malloc
(
strlen
(
p
)
+
1
);
copyp
=
copy
;
while
(
*
p
!=
'\0'
)
{
if
((
*
p
==
'/'
)
&&
(
copyp
==
copy
))
{
/* remove leading slash */
p
++
;
}
else
if
((
*
p
==
'.'
)
&&
(
*
(
p
+
1
)
==
'.'
)
&&
((
*
(
p
+
2
)
==
'/'
)
||
(
*
(
p
+
2
)
==
'\0'
)))
{
/* remove .. followed by slash or end */
p
+=
2
;
if
(
copyp
!=
copy
)
{
/* backup the copy one level */
while
((
--
copyp
!=
copy
)
&&
(
*
copyp
==
'/'
))
/* skip trailing slashes */
;
while
((
copyp
!=
copy
)
&&
(
*
copyp
!=
'/'
))
/* skip back through slash */
copyp
--
;
}
}
else
{
/* copy one component */
while
(
1
)
{
*
copyp
++
=
*
p
++
;
if
((
*
p
==
'\0'
)
||
(
*
(
p
-
1
)
==
'/'
))
break
;
}
}
}
*
copyp
=
'\0'
;
return
(
copy
);
}
/****************************************************************************
return the date and time as a string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment