Incremental parsing fixes
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 5 Oct 2014 20:52:59 +0000 (22:52 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 5 Oct 2014 20:52:59 +0000 (22:52 +0200)
src/libimcv/ietf/ietf_attr_installed_packages.c
src/libimcv/tcg/swid/tcg_swid_attr_tag_inv.c

index 155a782..39eea55 100644 (file)
@@ -203,7 +203,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        while (this->count)
        {
-               if (!reader->read_data8(reader, &name))
+               if (!reader->read_data8(reader, &name) ||
+                       !reader->read_data8(reader, &version))
                {
                        goto end;
                }
@@ -215,21 +216,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
                        status = FAILED;
                        goto end;
                }
-               this->offset += 1 + name.len;
-
-               if (!reader->read_data8(reader, &version))
-               {
-                       goto end;
-               }
                pos = memchr(version.ptr, '\0', version.len);
                if (pos)
                {
                        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;
                        goto end;
                }
-               this->offset += 1 + version.len;
+               this->offset += this->value.len - reader->remaining(reader);
                this->value = reader->peek(reader);
 
                entry = malloc_thing(package_entry_t);
@@ -326,7 +321,7 @@ METHOD(ietf_attr_installed_packages_t, clear_packages, void,
 {
        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);
        }
index ade0ca8..0134824 100644 (file)
@@ -189,8 +189,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
        {
                if (this->length < TCG_SWID_TAG_INV_MIN_SIZE)
                {
-                       DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names,
-                                                                                                         this->type.type);
+                       DBG1(DBG_TNC, "insufficient data for %N/%N", pen_names, PEN_TCG,
+                                                  tcg_attr_names, this->type.type);
                        *offset = this->offset;
                        return FAILED;
                }
@@ -230,8 +230,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        if (this->length != this->offset)
        {
-               DBG1(DBG_TNC, "inconsistent length for %N", tcg_attr_names,
-                                                                                                       this->type.type);
+               DBG1(DBG_TNC, "inconsistent length for %N/%N", pen_names, PEN_TCG,
+                                          tcg_attr_names, this->type.type);
                *offset = this->offset;
                status = FAILED;
        }