[mpd] Check upper bound for sticker 'rating'

This commit is contained in:
chme 2017-12-10 09:31:00 +01:00 committed by ejurgensen
parent 7a916c84a2
commit 7b04787fc1
2 changed files with 8 additions and 0 deletions

View File

@ -72,6 +72,8 @@ enum query_type {
#define DB_ADMIN_LASTFM_SESSION_KEY "lastfm_sk"
#define DB_ADMIN_SPOTIFY_REFRESH_TOKEN "spotify_refresh_token"
#define DB_FILES_RATING_MAX 100
struct query_params {
/* Query parameters, filled in by caller */
enum query_type type;

View File

@ -3301,6 +3301,12 @@ mpd_sticker_set(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, co
}
rating *= MPD_RATING_FACTOR;
if (rating > DB_FILES_RATING_MAX)
{
*errmsg = safe_asprintf("rating '%s' is greater than maximum value allowed", argv[5], (DB_FILES_RATING_MAX / MPD_RATING_FACTOR));
return ACK_ERROR_ARG;
}
ret = db_file_rating_update_byvirtualpath(virtual_path, rating);
if (ret <= 0)
{