When lib path is zeroed daemon was crushed.
return (unsigned int)MAX_ERROR_BUF_PATH;
}
-int update_errno_buffer(const char *buffer)
+int update_errno_buffer(char *buffer, const unsigned int type)
{
unsigned int size;
+ char* tmp_buffer;
+ int return_value = 0;
if (last_error == NULL) {
if (create_errno_buffer() != 0)
return -1;
}
- size = strlen(buffer);
+ if (buffer == NULL) {
+ if (type == IS_LIB) {
+ tmp_buffer = "Unknown lib path. Zero pointer";
+ } else if(type == IS_APP) {
+ tmp_buffer = "Unknown app path. Zero pointer";
+ } else {
+ tmp_buffer = "Undefined instrumentation type. Zero pointer";
+ }
+
+ return_value = -1;
+ } else {
+ tmp_buffer = buffer;
+ }
+
+ size = strlen(tmp_buffer);
if (last_error->size + size + 2 >= get_max_error_buffer_size()) {
return -1;
}
- strncat((char*)(last_error->buffer), buffer, size);
+ strncat((char*)(last_error->buffer), tmp_buffer, size);
last_error->size += size + 1;
last_error->buffer[last_error->size - 1] = ',';
last_error->buffer[last_error->size] = '\0';
- return 0;
+ return return_value;
}
static void delete_errno_buffer(void)
#define MAX_ERROR_BUF_PATH 256
+#define IS_APP 0
+#define IS_LIB 1
// copy error buffer from kernelspace to userspace
int get_last_error(void* u_addr);
int has_last_error(void);
-int update_errno_buffer(const char *buffer);
+int update_errno_buffer(char *buffer, const unsigned int type);
if (strcmp(us_proc_info.path, "*")) {
us_proc_info.m_f_dentry = dentry_by_path(us_proc_info.path);
if (us_proc_info.m_f_dentry == NULL) {
- update_errno_buffer(us_proc_info.path);
+ update_errno_buffer(us_proc_info.path, IS_APP);
return -1;
}
}
{
if (strcmp(d_lib->path_dyn, "") == 0) {
EPRINTF("Cannot find path for lib %s!", d_lib->path);
- update_errno_buffer(d_lib->path);
+ if (update_errno_buffer(d_lib->path, IS_LIB) == -1) {
+ return -1;
+ }
/* Just skip all the IPs and go to next lib */
p += d_lib->ips_count * 3 * sizeof(u_int32_t);
d_lib->ips_count = 0;
d_lib->m_f_dentry = dentry_by_path(d_lib->path);
if (d_lib->m_f_dentry == NULL) {
EPRINTF ("failed to lookup dentry for path %s!", d_lib->path);
- update_errno_buffer(d_lib->path);
+ if (update_errno_buffer(d_lib->path, IS_LIB) == -1) {
+ return -1;
+ }
/* Just skip all the IPs and go to next lib */
p += d_lib->ips_count * 3 * sizeof(u_int32_t);
d_lib->ips_count = 0;