diff mbox

[05/23] ndef: Discard records containing errors

Message ID 20170615182516.4508-6-mgreer@animalcreek.com (mailing list archive)
State Accepted
Delegated to: Samuel Ortiz
Headers show

Commit Message

Mark Greer June 15, 2017, 6:24 p.m. UTC
Currently, near_ndef_parse_msg() adds records even when they contain
erroneous record types.  This can later cause neard to exit when it
tries to signal dbus with incomplete record information.  Avoid this
by ignoring records that contain bad record types (and all of the
records that follow in the same NDEF message).

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
---
 src/ndef.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/ndef.c b/src/ndef.c
index 7a3c76b..38dcf72 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -2845,7 +2845,6 @@  GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length,
 		case RECORD_TYPE_WKT_COLLISION_RESOLUTION:
 		case RECORD_TYPE_WKT_ERROR:
 		case RECORD_TYPE_UNKNOWN:
-		case RECORD_TYPE_ERROR:
 			break;
 
 		case RECORD_TYPE_WKT_HANDOVER_REQUEST:
@@ -2927,6 +2926,8 @@  GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length,
 				goto fail;
 
 			break;
+		case RECORD_TYPE_ERROR:
+			goto fail;
 		}
 
 		record->data_len = record->header->header_len +