[jsonapi] Check for empty playlist name in queue/save

This commit is contained in:
chme 2019-05-30 11:13:26 +02:00
parent 3650a7573f
commit 4434fe7a2c

View File

@ -2917,9 +2917,9 @@ static int
jsonapi_reply_queue_save(struct httpd_request *hreq) jsonapi_reply_queue_save(struct httpd_request *hreq)
{ {
const char *param; const char *param;
int ret = 0;
char buf[PATH_MAX+7]; char buf[PATH_MAX+7];
char *plsname = NULL; char *playlist_name = NULL;
int ret = 0;
if ((param = evhttp_find_header(hreq->query, "name")) == NULL) if ((param = evhttp_find_header(hreq->query, "name")) == NULL)
{ {
@ -2939,9 +2939,17 @@ jsonapi_reply_queue_save(struct httpd_request *hreq)
return 403; return 403;
} }
plsname = atrim(param); playlist_name = atrim(param);
snprintf(buf, PATH_MAX+7, "/file:%s/%s", default_pl_dir, plsname);
free(plsname); if (strlen(playlist_name) < 1) {
free(playlist_name);
DPRINTF(E_LOG, L_WEB, "Empty playlist name parameter is not allowed\n");
return HTTP_BADREQUEST;
}
snprintf(buf, sizeof(buf), "/file:%s/%s", default_pl_dir, playlist_name);
free(playlist_name);
ret = library_queue_save(buf); ret = library_queue_save(buf);