mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-21 08:56:56 -05:00
pulse-server: return length of TAG_ARBITRARY
So that we don't have to know the length beforehand but can still check it.
This commit is contained in:
parent
bc46ead017
commit
bba24b9ff8
2 changed files with 12 additions and 9 deletions
|
|
@ -135,6 +135,7 @@ static int read_props(struct message *m, struct pw_properties *props)
|
||||||
char *key;
|
char *key;
|
||||||
void *data;
|
void *data;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
if ((res = message_get(m,
|
if ((res = message_get(m,
|
||||||
TAG_STRING, &key,
|
TAG_STRING, &key,
|
||||||
|
|
@ -152,28 +153,27 @@ static int read_props(struct message *m, struct pw_properties *props)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if ((res = message_get(m,
|
if ((res = message_get(m,
|
||||||
TAG_ARBITRARY, &data, length,
|
TAG_ARBITRARY, &data, &size,
|
||||||
TAG_INVALID)) < 0)
|
TAG_INVALID)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
pw_log_debug("%s %s", key, (char*)data);
|
|
||||||
pw_properties_set(props, key, data);
|
pw_properties_set(props, key, data);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_arbitrary(struct message *m, const void **val, size_t length)
|
static int read_arbitrary(struct message *m, const void **val, size_t *length)
|
||||||
{
|
{
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
int res;
|
int res;
|
||||||
if ((res = read_u32(m, &len)) < 0)
|
if ((res = read_u32(m, &len)) < 0)
|
||||||
return res;
|
return res;
|
||||||
if (len != length)
|
if (m->offset + len > m->length)
|
||||||
return -EINVAL;
|
|
||||||
if (m->offset + length > m->length)
|
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
*val = m->data + m->offset;
|
*val = m->data + m->offset;
|
||||||
m->offset += length;
|
m->offset += len;
|
||||||
|
if (length)
|
||||||
|
*length = len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ static int message_get(struct message *m, ...)
|
||||||
case TAG_ARBITRARY:
|
case TAG_ARBITRARY:
|
||||||
{
|
{
|
||||||
const void **val = va_arg(va, const void**);
|
const void **val = va_arg(va, const void**);
|
||||||
size_t len = va_arg(va, size_t);
|
size_t *len = va_arg(va, size_t*);
|
||||||
if (dtag != tag)
|
if (dtag != tag)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if ((res = read_arbitrary(m, val, len)) < 0)
|
if ((res = read_arbitrary(m, val, len)) < 0)
|
||||||
|
|
|
||||||
|
|
@ -449,15 +449,18 @@ static int do_command_auth(struct client *client, uint32_t command, uint32_t tag
|
||||||
struct message *reply;
|
struct message *reply;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
const void *cookie;
|
const void *cookie;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (message_get(m,
|
if (message_get(m,
|
||||||
TAG_U32, &version,
|
TAG_U32, &version,
|
||||||
TAG_ARBITRARY, &cookie, NATIVE_COOKIE_LENGTH,
|
TAG_ARBITRARY, &cookie, &len,
|
||||||
TAG_INVALID) < 0) {
|
TAG_INVALID) < 0) {
|
||||||
return -EPROTO;
|
return -EPROTO;
|
||||||
}
|
}
|
||||||
if (version < 8)
|
if (version < 8)
|
||||||
return -EPROTO;
|
return -EPROTO;
|
||||||
|
if (len != NATIVE_COOKIE_LENGTH)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if ((version & PROTOCOL_VERSION_MASK) >= 13)
|
if ((version & PROTOCOL_VERSION_MASK) >= 13)
|
||||||
version &= PROTOCOL_VERSION_MASK;
|
version &= PROTOCOL_VERSION_MASK;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue