diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-01-13 02:03:48 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-01-13 02:03:48 +0200 |
commit | 9f5db347f079b68efe2cca677df8be7b3b830e9c (patch) | |
tree | 245940c40bee073e246d09e005e0ecb37e03b25e | |
parent | 876672aa99ccdd63151cbe03c3cf04aa2d3fddec (diff) | |
download | bluez-9f5db347f079b68efe2cca677df8be7b3b830e9c.tar.gz |
eir: Fix modifying field_len when parsing
The field_len variable shouldn't be touched for the over-all parsing
state to remain consistent and so a helper variable (name_len) is needed
after all.
-rw-r--r-- | src/eir.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -119,6 +119,7 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len) while (len < eir_len - 1) { uint8_t field_len = eir_data[0]; + uint8_t name_len; /* Check for the end of EIR */ if (field_len == 0) @@ -156,11 +157,13 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len) case EIR_NAME_COMPLETE: /* Some vendors put a NUL byte terminator into * the name */ - while (field_len > 1 && eir_data[field_len] == '\0') - field_len--; + name_len = field_len - 1; + + while (name_len > 0 && eir_data[name_len - 1] == '\0') + name_len--; if (!g_utf8_validate((char *) &eir_data[2], - field_len - 1, NULL)) + name_len, NULL)) break; g_free(eir->name); |