Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
f19a9bb4
...
f19a9bb4c63b6eaa28c2e5e480f9207d76e625a7
authored
2005-11-28 11:16:48 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mh_expand_name): Make sure the returned value can safely be freed.
1 parent
fa22b724
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
mh/mh_init.c
mh/mh_init.c
View file @
f19a9bb
...
...
@@ -404,39 +404,35 @@ mh_get_dir ()
char
*
mh_expand_name
(
const
char
*
base
,
const
char
*
name
,
int
is_folder
)
{
char
*
tmp
=
NULL
;
char
*
p
=
NULL
;
char
*
namep
;
char
*
namep
=
NULL
;
tm
p
=
mu_tilde_expansion
(
name
,
"/"
,
NULL
);
if
(
tm
p
[
0
]
==
'+'
)
namep
=
tmp
+
1
;
else
if
(
strncmp
(
tmp
,
"../"
,
3
)
==
0
||
strncmp
(
tm
p
,
"./"
,
2
)
==
0
)
name
p
=
mu_tilde_expansion
(
name
,
"/"
,
NULL
);
if
(
name
p
[
0
]
==
'+'
)
memmove
(
namep
,
namep
+
1
,
strlen
(
namep
));
/* copy null byte as well */
else
if
(
strncmp
(
namep
,
"../"
,
3
)
==
0
||
strncmp
(
name
p
,
"./"
,
2
)
==
0
)
{
char
*
cwd
=
mu_getcwd
();
asprintf
(
&
namep
,
"%s/%s"
,
cwd
,
tmp
);
char
*
tmp
=
NULL
;
asprintf
(
&
tmp
,
"%s/%s"
,
cwd
,
namep
);
free
(
cwd
);
free
(
tmp
);
tmp
=
NULL
;
}
else
free
(
namep
);
namep
=
tmp
;
}
if
(
!
base
)
base
=
mu_folder_directory
();
if
(
is_folder
)
{
if
(
namep
[
0
]
==
'/'
)
asprintf
(
&
p
,
"mh:%s"
,
namep
);
else
asprintf
(
&
p
,
"mh:%s/%s"
,
base
,
namep
);
asprintf
(
&
p
,
"mh:%s/%s"
,
base
?
base
:
mu_folder_directory
()
,
namep
);
}
else
if
(
namep
[
0
]
!=
'/'
)
asprintf
(
&
p
,
"%s/%s"
,
base
,
namep
);
asprintf
(
&
p
,
"%s/%s"
,
base
?
base
:
mu_folder_directory
()
,
namep
);
else
return
namep
;
free
(
tm
p
);
free
(
name
p
);
return
p
;
}
...
...
Please
register
or
sign in
to post a comment