Only do hex conversion if param is 0x-format. Also accept song-spec from Retune (issue #90).

This commit is contained in:
ejurgensen 2015-01-26 22:37:02 +01:00
parent 77f206c118
commit dccbe92a75
2 changed files with 12 additions and 9 deletions

View File

@ -638,10 +638,13 @@ dacp_propset_userrating(const char *value, struct evkeyvalq *query)
return;
}
param = evhttp_find_header(query, "item-spec");
param = evhttp_find_header(query, "item-spec"); // Remote
if (!param)
param = evhttp_find_header(query, "song-spec"); // Retune
if (!param)
{
DPRINTF(E_LOG, L_DACP, "Missing item-spec parameter in dacp.userrating query\n");
DPRINTF(E_LOG, L_DACP, "Missing item-spec/song-spec parameter in dacp.userrating query\n");
return;
}
@ -649,7 +652,7 @@ dacp_propset_userrating(const char *value, struct evkeyvalq *query)
param = strchr(param, ':');
if (!param)
{
DPRINTF(E_LOG, L_DACP, "Malformed item-spec parameter in dacp.userrating query\n");
DPRINTF(E_LOG, L_DACP, "Malformed item-spec/song-spec parameter in dacp.userrating query\n");
return;
}
@ -658,7 +661,7 @@ dacp_propset_userrating(const char *value, struct evkeyvalq *query)
ret = safe_hextou32(param, &itemid);
if (ret < 0)
{
DPRINTF(E_LOG, L_DACP, "Couldn't convert item-spec to an integer in dacp.userrating (%s)\n", param);
DPRINTF(E_LOG, L_DACP, "Couldn't convert item-spec/song-spec to an integer in dacp.userrating (%s)\n", param);
return;
}
@ -2093,12 +2096,8 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
do
{
param++;
/* Hyperfine Remote for Android will send in decimal, others use hex */
if ((strlen(param) > 1) && (param[1] != 'x'))
ret = safe_atou64(param, &ids[i]);
else
ret = safe_hextou64(param, &ids[i]);
ret = safe_hextou64(param, &ids[i]);
if (ret < 0)
{
DPRINTF(E_LOG, L_DACP, "Invalid speaker id in request: %s\n", param);

View File

@ -119,6 +119,10 @@ safe_hextou32(const char *str, uint32_t *val)
char *end;
unsigned long intval;
/* A hex shall begin with 0x */
if (strncmp(str, "0x", 2) != 0)
return safe_atou32(str, val);
errno = 0;
intval = strtoul(str, &end, 16);