OSDN Git Service

unit/avrcp: Fix possible buffer overflow
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Mon, 31 Mar 2014 12:25:12 +0000 (15:25 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 2 Apr 2014 11:25:42 +0000 (14:25 +0300)
text[] needs to be of size number for get_value_text()

unit/test-avrcp.c

index 868d350..d4d26be 100644 (file)
@@ -431,10 +431,15 @@ static int get_value_text(struct avrcp *session, uint8_t transaction,
                                uint8_t attr, uint8_t number, uint8_t *values,
                                void *user_data)
 {
-       const char *text[] = { "on" };
+       const char *text[number];
 
        DBG("");
 
+       if (number) {
+               memset(text, 0, number);
+               text[0] = "on";
+       }
+
        avrcp_get_player_values_text_rsp(session, transaction, number,
                                                                values, text);