Skip to content

Commit

Permalink
Removed creation of additional external img info and bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Mar 20, 2014
1 parent 403aa1b commit c8d57e3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 66 deletions.
5 changes: 3 additions & 2 deletions class_parser.py
Expand Up @@ -234,7 +234,7 @@
DEBUG = 0

# The pytsk3 version
VERSION = "20140319"
VERSION = "20140320"

# These functions are used to manage library memory
FREE = "aff4_free"
Expand Down Expand Up @@ -289,7 +289,8 @@ def initialization(self):
"\n"
"talloc_set_log_fn((void (*)(const char *)) printf);\n"
"// DEBUG: talloc_enable_leak_report();\n"
"// DEBUG: talloc_enable_leak_report_full();\n")
"// DEBUG: talloc_enable_leak_report_full();\n"
"talloc_enable_leak_report_full();\n")

for cls in self.classes.values():
if cls.is_active():
Expand Down
4 changes: 2 additions & 2 deletions dpkg/changelog
@@ -1,5 +1,5 @@
pytsk (4.1.2-20140319-1) unstable; urgency=low
pytsk (4.1.2-20140320-1) unstable; urgency=low

* Auto-generated

-- Joachim Metz <joachim.metz@gmail.com> Wed, 19 Mar 2014 22:12:04 +0100
-- Joachim Metz <joachim.metz@gmail.com> Thu, 20 Mar 2014 20:57:33 +0100
68 changes: 11 additions & 57 deletions tsk3.c
Expand Up @@ -139,39 +139,6 @@ void Img_Info_close(Img_Info self) {
}
}

Extended_TSK_IMG_INFO *Img_Info_get_img_info(Img_Info self) {
// Initialise the img struct with the correct callbacks:
Extended_TSK_IMG_INFO *img = NULL;

if(self == NULL) {
RaiseError(EInvalidParameter, "Invalid parameter: self.");
return NULL;
}
// Create a new talloc context here since we do not want to
// unnecessarily keep unused versions around.
img = talloc_zero(NULL, Extended_TSK_IMG_INFO);
img->container = self;

#if defined( TSK_MULTITHREAD_LIB )
tsk_init_lock(&img->base.cache_lock);
#endif

img->base.read = IMG_INFO_read;
img->base.close = IMG_INFO_close;
img->base.size = self->get_size(self);

#ifdef TSK_VERSION_NUM
img->base.sector_size = 512;
#endif
#if defined( TSK_VERSION_NUM ) && ( TSK_VERSION_NUM >= 0x040103ff )
self->img->base.itype = TSK_IMG_TYPE_EXTERNAL;
#else
img->base.itype = TSK_IMG_TYPE_RAW_SING;
#endif

return img;
}

uint64_t Img_Info_get_size(Img_Info self) {
if(self == NULL) {
RaiseError(EInvalidParameter, "Invalid parameter: self.");
Expand All @@ -187,7 +154,6 @@ VIRTUAL(Img_Info, Object) {
VMETHOD(Con) = Img_Info_Con;
VMETHOD(read) = Img_Info_read;
VMETHOD(close) = Img_Info_close;
VMETHOD(get_img_info) = Img_Info_get_img_info;
VMETHOD(get_size) = Img_Info_get_size;
} END_VIRTUAL

Expand Down Expand Up @@ -216,8 +182,10 @@ int FS_Info_dest(FS_Info self) {

self->info = NULL;

#ifdef TODO
// The extended_img_info was allocated in a separate talloc context.
talloc_free(self->extended_img_info);
#endif
self->extended_img_info = NULL;

return 0;
Expand All @@ -235,32 +203,21 @@ static FS_Info FS_Info_Con(FS_Info self, Img_Info img, TSK_OFF_T offset,
RaiseError(EInvalidParameter, "Invalid parameter: img.");
return NULL;
}
// TODO: why is a new instance of img_info necessary here?
self->extended_img_info = img->get_img_info(img);
self->extended_img_info = img->img;

if(self->extended_img_info == NULL) {
RaiseError(EInvalidParameter, "Invalid self->extended_img_info");
goto on_error;
}
self->info = tsk_fs_open_img((TSK_IMG_INFO *) self->extended_img_info, offset, type);

if(!self->info) {
RaiseError(EIOError, "Unable to open the image as a filesystem: %s",
tsk_error_get());
tsk_error_reset();
goto on_error;
return NULL;
}
// Make sure that the filesystem is properly closed when we get freed
talloc_set_destructor((void *) self, (int(*)(void *)) &FS_Info_dest);

return self;

on_error:
if(self->extended_img_info != NULL) {
talloc_free(self->extended_img_info);
}
return NULL;
};
}

static Directory FS_Info_open_dir(FS_Info self, ZString path, TSK_INUM_T inode) {
Directory object = NULL;
Expand Down Expand Up @@ -310,10 +267,9 @@ static File FS_Info_open(FS_Info self, ZString path) {
if(CONSTRUCT_INITIALIZE(File, File, Con, object, self, info) == NULL) {
goto on_error;
}
// Tell the File object to manage info.
object->info_is_internal = 1;
}
// Tell the File object to manage info.
object->info_is_internal = 1;

return object;

on_error:
Expand Down Expand Up @@ -349,10 +305,9 @@ static File FS_Info_open_meta(FS_Info self, TSK_INUM_T inode) {
if(CONSTRUCT_INITIALIZE(File, File, Con, object, self, info) == NULL) {
goto on_error;
}
// Tell the File object to manage info.
object->info_is_internal = 1;
}
// Tell the File object to manage info.
object->info_is_internal = 1;

return object;

on_error:
Expand Down Expand Up @@ -455,10 +410,9 @@ static File Directory_next(Directory self) {
if(CONSTRUCT_INITIALIZE(File, File, Con, object, self->fs, info) == NULL) {
goto on_error;
}
// Tell the File object to manage info.
object->info_is_internal = 1;
}
// Tell the File object to manage info.
object->info_is_internal = 1;

self->current++;

return object;
Expand Down
5 changes: 0 additions & 5 deletions tsk3.h
Expand Up @@ -90,11 +90,6 @@ CLASS(Img_Info, Object)

/* Closes the image */
void METHOD(Img_Info, close);

/* An accessor for our img object - used by TSK classes to get
* our object.
*/
PRIVATE Extended_TSK_IMG_INFO *METHOD(Img_Info, get_img_info);
END_CLASS

/** This object handles volumes.
Expand Down

0 comments on commit c8d57e3

Please sign in to comment.