summaryrefslogtreecommitdiff
path: root/src/libpts/tcg/tcg_pts_attr_unix_file_meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libpts/tcg/tcg_pts_attr_unix_file_meta.c')
-rw-r--r--src/libpts/tcg/tcg_pts_attr_unix_file_meta.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libpts/tcg/tcg_pts_attr_unix_file_meta.c b/src/libpts/tcg/tcg_pts_attr_unix_file_meta.c
index 4f93ee885..56686d8ca 100644
--- a/src/libpts/tcg/tcg_pts_attr_unix_file_meta.c
+++ b/src/libpts/tcg/tcg_pts_attr_unix_file_meta.c
@@ -18,15 +18,17 @@
#include <pa_tnc/pa_tnc_msg.h>
#include <bio/bio_writer.h>
#include <bio/bio_reader.h>
-#include <utils/linked_list.h>
-#include <debug.h>
+#include <collections/linked_list.h>
+#include <utils/debug.h>
+
+#include <string.h>
typedef struct private_tcg_pts_attr_file_meta_t private_tcg_pts_attr_file_meta_t;
/**
* Unix-Style File Metadata
* see section 3.17.3 of PTS Protocol: Binding to TNC IF-M Specification
- *
+ *
* 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -88,12 +90,12 @@ struct private_tcg_pts_attr_file_meta_t {
* Attribute value
*/
chunk_t value;
-
+
/**
* Noskip flag
*/
bool noskip_flag;
-
+
/**
* PTS File Metadata
*/
@@ -136,7 +138,7 @@ METHOD(pa_tnc_attr_t, build, void,
enumerator_t *enumerator;
pts_file_metadata_t *entry;
u_int64_t number_of_files;
-
+
if (this->value.ptr)
{
return;
@@ -163,7 +165,7 @@ METHOD(pa_tnc_attr_t, build, void,
strlen(entry->filename)));
}
enumerator->destroy(enumerator);
-
+
this->value = chunk_clone(writer->get_buf(writer));
writer->destroy(writer);
}
@@ -179,7 +181,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
u_int64_t owner, group;
chunk_t filename;
status_t status = FAILED;
-
+
if (this->value.len < PTS_FILE_META_SIZE)
{
DBG1(DBG_TNC, "insufficient data for PTS Unix-Style file metadata header");
@@ -190,7 +192,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
reader->read_uint64(reader, &number_of_files);
this->metadata = pts_file_meta_create();
-
+
while (number_of_files--)
{
if (!reader->read_uint16(reader, &len))
@@ -243,7 +245,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
DBG1(DBG_TNC, "insufficient data for filename");
goto end;
}
-
+
entry = malloc_thing(pts_file_metadata_t);
entry->type = type;
entry->filesize = filesize;
@@ -252,9 +254,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
entry->accessed = accessed;
entry->owner = owner;
entry->group = group;
- entry->filename = malloc(filename.len + 1);
- entry->filename[filename.len] = '\0';
- memcpy(entry->filename, filename.ptr, filename.len);
+ entry->filename = strndup(filename.ptr, filename.len);
this->metadata->add(this->metadata, entry);
}
@@ -277,7 +277,7 @@ METHOD(pa_tnc_attr_t, destroy, void,
{
if (ref_put(&this->ref))
{
- this->metadata->destroy(this->metadata);
+ DESTROY_IF(this->metadata);
free(this->value.ptr);
free(this);
}