Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
2accfe55
Commit
2accfe55
authored
Feb 17, 2004
by
Karl Heyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix possible bad pointer reference when finding fallback mount
svn path=/trunk/icecast/; revision=5830
parent
012b3f42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
35 deletions
+36
-35
src/source.c
src/source.c
+36
-35
No files found.
src/source.c
View file @
2accfe55
...
@@ -145,55 +145,56 @@ source_t *source_find_mount_raw(const char *mount)
...
@@ -145,55 +145,56 @@ source_t *source_find_mount_raw(const char *mount)
return
NULL
;
return
NULL
;
}
}
static
source_t
*
source_find_mount_recursive
(
const
char
*
mount
,
int
depth
)
/* Search for mount, if the mount is there but not currently running then
* check it's fallback, and so on. Must have a global source lock to call
* this function.
*/
source_t
*
source_find_mount
(
const
char
*
mount
)
{
{
source_t
*
source
=
source_find_mount_raw
(
mount
);
source_t
*
source
=
NULL
;
mount_proxy
*
mountinfo
;
ice_config_t
*
config
;
ice_config_t
*
config
;
char
*
fallback_mount
;
mount_proxy
*
mountinfo
;
int
depth
=
0
;
if
(
source
==
NULL
)
{
if
(
depth
>
MAX_FALLBACK_DEPTH
)
return
NULL
;
/* Look for defined mounts to find a fallback source */
config
=
config_get_config
();
while
(
mount
!=
NULL
)
{
/* limit the number of times through, maybe infinite */
if
(
depth
>
MAX_FALLBACK_DEPTH
)
{
source
=
NULL
;
break
;
}
config
=
config_get_config
();
source
=
source_find_mount_raw
(
mount
);
mountinfo
=
config
->
mounts
;
if
(
source
==
NULL
)
thread_mutex_lock
(
&
(
config_locks
()
->
mounts_lock
));
break
;
/* fallback to missing mountpoint */
config_release_config
();
while
(
mountinfo
)
{
if
(
source
->
running
)
if
(
!
strcmp
(
mountinfo
->
mountname
,
mount
))
break
;
/* source is not running, meaning that the fallback is not configured
within the source, we need to check the mount list */
mountinfo
=
config
->
mounts
;
source
=
NULL
;
while
(
mountinfo
)
{
if
(
strcmp
(
mountinfo
->
mountname
,
mount
)
==
0
)
break
;
break
;
mountinfo
=
mountinfo
->
next
;
mountinfo
=
mountinfo
->
next
;
}
}
if
(
mountinfo
)
if
(
mountinfo
)
mount
=
mountinfo
->
fallback_mount
;
fallback_mount
=
mountinfo
->
fallback_mount
;
else
else
fallback_mount
=
NULL
;
mount
=
NULL
;
depth
++
;
thread_mutex_unlock
(
&
(
config_locks
()
->
mounts_lock
));
if
(
fallback_mount
!=
NULL
)
{
return
source_find_mount_recursive
(
fallback_mount
,
depth
+
1
);
}
}
}
config_release_config
();
return
source
;
return
source
;
}
}
/* you must already have a read lock on the global source tree
** to call this function
*/
source_t
*
source_find_mount
(
const
char
*
mount
)
{
if
(
!
mount
)
return
NULL
;
return
source_find_mount_recursive
(
mount
,
0
);
}
int
source_compare_sources
(
void
*
arg
,
void
*
a
,
void
*
b
)
int
source_compare_sources
(
void
*
arg
,
void
*
a
,
void
*
b
)
{
{
...
...
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