Disallow silly things like ${playlist//} and trailing slashes ${playlist/0/}.
Unified · Split
| @@ -617,19 +617,17 @@ int m_property_read_list(int action, void *arg, int count, · 616 unmodified lines | |||
| 617 | return M_PROPERTY_NOT_IMPLEMENTED; | 617 | return M_PROPERTY_NOT_IMPLEMENTED; |
| 618 | } | 618 | } |
| 619 | // This is expected of the form "123" or "123/rest" | 619 | // This is expected of the form "123" or "123/rest" |
| 620 | char *next = strchr(ka->key, '/'); | 620 | char *end; |
| 621 | char *end = NULL; | ||
| 622 | const char *key_end = ka->key + strlen(ka->key); | ||
| 623 | long int item = strtol(ka->key, &end, 10); | 621 | long int item = strtol(ka->key, &end, 10); |
| 624 | // not a number, trailing characters, etc. | 622 | // not a number, trailing characters, etc. |
| 625 | if ((end != key_end || ka->key == key_end) && end != next) | 623 | if (end == ka->key || (end[0] == '/' && !end[1])) |
| 626 | return M_PROPERTY_UNKNOWN; | 624 | return M_PROPERTY_UNKNOWN; |
| 627 | if (item < 0 || item >= count) | 625 | if (item < 0 || item >= count) |
| 628 | return M_PROPERTY_UNKNOWN; | 626 | return M_PROPERTY_UNKNOWN; |
| 629 | if (next) { | 627 | if (*end) { |
| 630 | // Sub-path | 628 | // Sub-path |
| 631 | struct m_property_action_arg n_ka = *ka; | 629 | struct m_property_action_arg n_ka = *ka; |
| 632 | n_ka.key = next + 1; | 630 | n_ka.key = end + 1; |
| 633 | return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx); | 631 | return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx); |
| 634 | } else { | 632 | } else { |
| 635 | // Direct query | 633 | // Direct query |