Incremental parsing fixes

This commit is contained in:
Andreas Steffen 2014-10-05 22:52:59 +02:00
parent 73af3a1b04
commit b95b664644
2 changed files with 9 additions and 14 deletions

View File

@ -203,7 +203,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
while (this->count) while (this->count)
{ {
if (!reader->read_data8(reader, &name)) if (!reader->read_data8(reader, &name) ||
!reader->read_data8(reader, &version))
{ {
goto end; goto end;
} }
@ -215,21 +216,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
status = FAILED; status = FAILED;
goto end; goto end;
} }
this->offset += 1 + name.len;
if (!reader->read_data8(reader, &version))
{
goto end;
}
pos = memchr(version.ptr, '\0', version.len); pos = memchr(version.ptr, '\0', version.len);
if (pos) if (pos)
{ {
DBG1(DBG_TNC, "nul termination in IETF installed package version"); DBG1(DBG_TNC, "nul termination in IETF installed package version");
*offset = this->offset + 1 + (pos - version.ptr); *offset = this->offset + 1 + name.len + 1 + (pos - version.ptr);
status = FAILED; status = FAILED;
goto end; goto end;
} }
this->offset += 1 + version.len; this->offset += this->value.len - reader->remaining(reader);
this->value = reader->peek(reader); this->value = reader->peek(reader);
entry = malloc_thing(package_entry_t); entry = malloc_thing(package_entry_t);
@ -326,7 +321,7 @@ METHOD(ietf_attr_installed_packages_t, clear_packages, void,
{ {
package_entry_t *entry; package_entry_t *entry;
while (this->packages->remove_first(this->packages,(void**)&entry)) while (this->packages->remove_first(this->packages,(void**)&entry) == SUCCESS)
{ {
free_package_entry(entry); free_package_entry(entry);
} }

View File

@ -189,8 +189,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
{ {
if (this->length < TCG_SWID_TAG_INV_MIN_SIZE) if (this->length < TCG_SWID_TAG_INV_MIN_SIZE)
{ {
DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names, DBG1(DBG_TNC, "insufficient data for %N/%N", pen_names, PEN_TCG,
this->type.type); tcg_attr_names, this->type.type);
*offset = this->offset; *offset = this->offset;
return FAILED; return FAILED;
} }
@ -230,8 +230,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
if (this->length != this->offset) if (this->length != this->offset)
{ {
DBG1(DBG_TNC, "inconsistent length for %N", tcg_attr_names, DBG1(DBG_TNC, "inconsistent length for %N/%N", pen_names, PEN_TCG,
this->type.type); tcg_attr_names, this->type.type);
*offset = this->offset; *offset = this->offset;
status = FAILED; status = FAILED;
} }