From 47f1d3fd21b79663891db6e2db7ee57e675e6d2f Mon Sep 17 00:00:00 2001 From: Kudrjavtsev Nickita Date: Mon, 18 Mar 2013 19:29:02 +0400 Subject: [PATCH] [FIX] fixing problem from Barinov when __switch_to was't collected --- driver/device_driver.c | 3 +++ driver/error_storage.c | 19 +++++++++++++------ driver/error_storage.h | 1 + driver/storage.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/driver/device_driver.c b/driver/device_driver.c index 1699aee..1fe26d1 100644 --- a/driver/device_driver.c +++ b/driver/device_driver.c @@ -409,12 +409,15 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l } DPRINTF("Bundle has been copied successfully"); + last_error_buffer_initialize(); + if (link_bundle() == -1) { EPRINTF("Cannot link profile bundle!"); result = -1; break; } if (has_last_error() == -1) { + EPRINTF("last_error_buffer != NULL"); result = -1; } diff --git a/driver/error_storage.c b/driver/error_storage.c index 53f31f9..7e3dcaf 100644 --- a/driver/error_storage.c +++ b/driver/error_storage.c @@ -15,6 +15,11 @@ struct errno_struct static struct errno_struct *last_error = NULL; +void last_error_buffer_initialize(void) +{ + last_error = NULL; +} + static int create_errno_buffer(void) { struct errno_struct *error = NULL; @@ -47,15 +52,14 @@ int update_errno_buffer(const char *buffer) { unsigned int size; - if (last_error == NULL) - { + if (last_error == NULL) { if (create_errno_buffer() != 0) return -1; } size = strlen(buffer); - if (last_error->size + size + 1 >= get_max_error_buffer_size()) { + if (last_error->size + size + 2 >= get_max_error_buffer_size()) { return -1; } @@ -70,8 +74,9 @@ int update_errno_buffer(const char *buffer) static void delete_errno_buffer(void) { - if (last_error == NULL) + if (last_error == NULL) { return; + } vfree((char*)last_error->buffer); vfree(last_error); @@ -85,8 +90,9 @@ int get_last_error(void* u_addr) { int result; - if (last_error == NULL) + if (last_error == NULL) { return -1; + } result = copy_to_user ((void*)u_addr, (void*)(last_error->buffer), last_error->size + 1); if (result) { @@ -100,7 +106,8 @@ int get_last_error(void* u_addr) int has_last_error() { - if(last_error == NULL) + if(last_error == NULL) { return 0; + } return -1; } diff --git a/driver/error_storage.h b/driver/error_storage.h index d32b4f1..4ba8c29 100644 --- a/driver/error_storage.h +++ b/driver/error_storage.h @@ -4,3 +4,4 @@ int get_last_error(void* u_addr); int has_last_error(void); int update_errno_buffer(const char *buffer); +void last_error_buffer_initialize(void); diff --git a/driver/storage.h b/driver/storage.h index a778091..91314d5 100644 --- a/driver/storage.h +++ b/driver/storage.h @@ -32,6 +32,7 @@ extern int update_errno_buffer(const char *buffer); extern int get_last_error(void* u_addr); extern int has_last_error(void); +extern void last_error_buffer_initialize(void); /////////////////////////////////////////////////////////////////////////////////////////////////// extern int EnableContinuousRetrieval(void); -- 2.7.4