s1245: Enforce the 5-points-per-response limit on media queries.

This commit is contained in:
Solomon Peachy 2015-08-20 22:41:58 -04:00
parent d4f00ec378
commit 28645830f5

View file

@ -289,11 +289,13 @@ struct shinkos1245_mediadesc {
uint8_t reserved[3];
} __attribute__((packed));
#define NUM_MEDIAS 5 /* Maximum per message */
struct shinkos1245_resp_media {
uint8_t code;
uint8_t reserved[5];
uint8_t count; /* 1-5? */
struct shinkos1245_mediadesc data[5];
struct shinkos1245_mediadesc data[NUM_MEDIAS];
} __attribute__((packed));
enum {
@ -510,6 +512,9 @@ static int shinkos1245_get_media(struct shinkos1245_ctx *ctx)
return -99;
}
if (resp.count > NUM_MEDIAS)
resp.count = NUM_MEDIAS;
/* Store media info */
for (j = 0; j < resp.count ; j++) {
ctx->medias[ctx->num_medias].code = resp.data[j].code;