Skip to content

Commit

Permalink
m_property: fix playlist property parsing
Browse files Browse the repository at this point in the history
Disallow silly things like ${playlist//} and trailing slashes
${playlist/0/}.
  • Loading branch information
kasper93 authored and Dudemanguy committed Feb 8, 2025
1 parent 3c1ddc4 commit 95019fc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions options/m_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,19 +617,17 @@ int m_property_read_list(int action, void *arg, int count,
return M_PROPERTY_NOT_IMPLEMENTED;
}
// This is expected of the form "123" or "123/rest"
char *next = strchr(ka->key, '/');
char *end = NULL;
const char *key_end = ka->key + strlen(ka->key);
char *end;
long int item = strtol(ka->key, &end, 10);
// not a number, trailing characters, etc.
if ((end != key_end || ka->key == key_end) && end != next)
if (end == ka->key || (end[0] == '/' && !end[1]))
return M_PROPERTY_UNKNOWN;
if (item < 0 || item >= count)
return M_PROPERTY_UNKNOWN;
if (next) {
if (*end) {
// Sub-path
struct m_property_action_arg n_ka = *ka;
n_ka.key = next + 1;
n_ka.key = end + 1;
return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx);
} else {
// Direct query
Expand Down

0 comments on commit 95019fc

Please # to comment.