From bacb9668655dd7ec93d70543ee2d03a60a467930 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Thu, 30 Jan 2014 18:49:18 +0000 Subject: [PATCH] check ATT_PROPERTY_WRITE for (prepare) write request and ATT_PROPERTY_WRITE_WITHOUT_RESPONSE for write command --- ble/att.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ble/att.c b/ble/att.c index 1268ed7b7..29ed6fae5 100644 --- a/ble/att.c +++ b/ble/att.c @@ -842,6 +842,9 @@ static uint16_t handle_write_request(att_connection_t * att_connection, uint8_t if (!att_write_callback) { return setup_error_write_not_permitted(response_buffer, request_type, handle); } + if ((it.flags & ATT_PROPERTY_WRITE) == 0) { + return setup_error_write_not_permitted(response_buffer, request_type, handle); + } if ((it.flags & ATT_PROPERTY_DYNAMIC) == 0) { return setup_error_write_not_permitted(response_buffer, request_type, handle); } @@ -872,6 +875,9 @@ static uint16_t handle_prepare_write_request(att_connection_t * att_connection, if (!ok) { return setup_error_invalid_handle(response_buffer, request_type, handle); } + if ((it.flags & ATT_PROPERTY_WRITE) == 0) { + return setup_error_write_not_permitted(response_buffer, request_type, handle); + } if ((it.flags & ATT_PROPERTY_DYNAMIC) == 0) { return setup_error_write_not_permitted(response_buffer, request_type, handle); } @@ -923,6 +929,7 @@ static void handle_write_command(att_connection_t * att_connection, uint8_t * re int ok = att_find_handle(&it, handle); if (!ok) return; if ((it.flags & ATT_PROPERTY_DYNAMIC) == 0) return; + if ((it.flags & ATT_PROPERTY_WRITE_WITHOUT_RESPONSE) == 0) return; (*att_write_callback)(handle, ATT_TRANSACTION_MODE_NONE, 0, request_buffer + 3, request_len - 3, NULL); }