diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2012-10-10 20:35:02 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-11 08:48:22 +0200 |
commit | f8619bef3406a2134082dc41c208105fe028c09f (patch) | |
tree | 8aee07ce1e9e9191d8e538dd0bef210833ca006a /src | |
parent | a48a3bac3ab1e12ea145ca46dd30cdf948761a73 (diff) |
attrib: Fix not checking if att_data_list_alloc fails
Now that this function may fail in more usual situations (invalid
input), we have to check its return value.
Diffstat (limited to 'src')
-rw-r--r-- | src/attrib-server.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/attrib-server.c b/src/attrib-server.c index ec4ecc36..7117fbe2 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -490,6 +490,9 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start, length = g_slist_length(groups); adl = att_data_list_alloc(length, last_size + 4); + if (adl == NULL) + return enc_error_resp(ATT_OP_READ_BY_GROUP_REQ, start, + ATT_ECODE_UNLIKELY, pdu, len); for (i = 0, l = groups; l; l = l->next, i++) { uint8_t *value; @@ -574,6 +577,9 @@ static uint16_t read_by_type(struct gatt_channel *channel, uint16_t start, length += 2; adl = att_data_list_alloc(num, length); + if (adl == NULL) + return enc_error_resp(ATT_OP_READ_BY_TYPE_REQ, start, + ATT_ECODE_UNLIKELY, pdu, len); for (i = 0, l = types; l; i++, l = l->next) { uint8_t *value; @@ -649,6 +655,9 @@ static uint16_t find_info(struct gatt_channel *channel, uint16_t start, } adl = att_data_list_alloc(num, length + 2); + if (adl == NULL) + return enc_error_resp(ATT_OP_FIND_INFO_REQ, start, + ATT_ECODE_UNLIKELY, pdu, len); for (i = 0, l = info; l; i++, l = l->next) { uint8_t *value; |