Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9fdac529
Commit
9fdac529
authored
Oct 31, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
path: removed sanitizePathDup()
We don't need to sanitize the path, because the mapper already checks for malformed paths.
parent
f2918767
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
47 deletions
+2
-47
command.c
src/command.c
+2
-4
path.c
src/path.c
+0
-40
path.h
src/path.h
+0
-3
No files found.
src/command.c
View file @
9fdac529
...
@@ -830,10 +830,8 @@ handle_update(struct client *client, mpd_unused int argc, char *argv[])
...
@@ -830,10 +830,8 @@ handle_update(struct client *client, mpd_unused int argc, char *argv[])
unsigned
ret
;
unsigned
ret
;
assert
(
argc
<=
2
);
assert
(
argc
<=
2
);
if
(
argc
==
2
&&
!
(
path
=
sanitizePathDup
(
argv
[
1
])))
{
if
(
argc
==
2
)
command_error
(
client
,
ACK_ERROR_ARG
,
"invalid path"
);
path
=
g_strdup
(
argv
[
1
]);
return
COMMAND_RETURN_ERROR
;
}
ret
=
directory_update_init
(
path
);
ret
=
directory_update_init
(
path
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
...
...
src/path.c
View file @
9fdac529
...
@@ -168,43 +168,3 @@ char *pfx_dir(char *dst,
...
@@ -168,43 +168,3 @@ char *pfx_dir(char *dst,
/* this is weird, but directory.c can use it more safely/efficiently */
/* this is weird, but directory.c can use it more safely/efficiently */
return
(
dst
+
pfx_len
+
1
);
return
(
dst
+
pfx_len
+
1
);
}
}
char
*
sanitizePathDup
(
const
char
*
path
)
{
int
len
=
strlen
(
path
)
+
1
;
char
*
ret
=
xmalloc
(
len
);
char
*
cp
=
ret
;
memset
(
ret
,
0
,
len
);
len
=
0
;
/* eliminate more than one '/' in a row, like "///" */
while
(
*
path
)
{
while
(
*
path
==
'/'
)
path
++
;
if
(
*
path
==
'.'
)
{
/* we don't want to have hidden directories, or '.' or
".." in our path */
free
(
ret
);
return
NULL
;
}
while
(
*
path
&&
*
path
!=
'/'
)
{
*
(
cp
++
)
=
*
(
path
++
);
len
++
;
}
if
(
*
path
==
'/'
)
{
*
(
cp
++
)
=
*
(
path
++
);
len
++
;
}
}
if
(
len
&&
ret
[
len
-
1
]
==
'/'
)
{
len
--
;
ret
[
len
]
=
'\0'
;
}
DEBUG
(
"sanitized: %s
\n
"
,
ret
);
return
xrealloc
(
ret
,
len
+
1
);
}
src/path.h
View file @
9fdac529
...
@@ -55,7 +55,4 @@ char *pfx_dir(char *dst,
...
@@ -55,7 +55,4 @@ char *pfx_dir(char *dst,
const
char
*
path
,
const
size_t
path_len
,
const
char
*
path
,
const
size_t
path_len
,
const
char
*
pfx
,
const
size_t
pfx_len
);
const
char
*
pfx
,
const
size_t
pfx_len
);
/* strips extra "///" and leading "/" and trailing "/" */
char
*
sanitizePathDup
(
const
char
*
path
);
#endif
#endif
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