Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nxssh
Project
Project
Details
Activity
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
rx-etersoft
nxssh
Commits
3c1abee4
Commit
3c1abee4
authored
Nov 15, 2016
by
Stas Korobeynikov
Committed by
Pavel Vainerman
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tildeexpand path
parent
696222ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
20 deletions
+8
-20
misc.c
misc.c
+8
-20
No files found.
misc.c
View file @
3c1abee4
...
...
@@ -609,7 +609,7 @@ char *
tilde_expand_filename
(
const
char
*
filename
,
uid_t
uid
)
{
const
char
*
path
,
*
sep
;
char
user
[
128
],
*
ret
;
char
user
[
128
],
*
ret
,
*
pwpath
;
struct
passwd
*
pw
;
u_int
len
,
slash
;
...
...
@@ -629,31 +629,19 @@ tilde_expand_filename(const char *filename, uid_t uid)
}
else
if
((
pw
=
getpwuid
(
uid
))
==
NULL
)
/* ~/path */
fatal
(
"tilde_expand_filename: No such uid %ld"
,
(
long
)
uid
);
if
(
options
.
home
)
{
if
(
strlcpy
(
ret
,
options
.
home
,
sizeof
(
ret
))
>=
sizeof
(
ret
))
fatal
(
"tilde_expand_filename: Path too long"
);
pwpath
=
options
.
home
?
options
.
home
:
pw
->
pw_dir
;
/* Make sure directory has a trailing '/' */
len
=
strlen
(
options
.
home
);
if
((
len
==
0
||
options
.
home
[
len
-
1
]
!=
'/'
)
&&
strlcat
(
ret
,
"/"
,
sizeof
(
ret
))
>=
sizeof
(
ret
))
fatal
(
"tilde_expand_filename: Path too long"
);
}
else
{
/* Make sure directory has a trailing '/' */
len
=
strlen
(
pw
->
pw_dir
);
if
(
len
==
0
||
pw
->
pw_dir
[
len
-
1
]
!=
'/'
)
sep
=
"/"
;
else
sep
=
""
;
}
len
=
strlen
(
pwpath
);
if
(
len
==
0
||
pwpath
[
len
-
1
]
!=
'/'
)
sep
=
"/"
;
else
sep
=
""
;
/* Skip leading '/' from specified path */
if
(
path
!=
NULL
)
filename
=
path
+
1
;
if
(
xasprintf
(
&
ret
,
"%s%s%s"
,
pw
->
pw_dir
,
sep
,
filename
)
>=
PATH_MAX
)
if
(
xasprintf
(
&
ret
,
"%s%s%s"
,
pw
path
,
sep
,
filename
)
>=
PATH_MAX
)
fatal
(
"tilde_expand_filename: Path too long"
);
return
(
ret
);
...
...
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