Commit 099bc6b6 authored by winckel's avatar winckel

Added a check on log strings to avoid issue with badly formated strings.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4946 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 07e5f883
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "struct_type.h" #include "struct_type.h"
#include "buffers.h" #include "buffers.h"
#include "ui_callbacks.h"
#include "ui_interface.h" #include "ui_interface.h"
int struct_dissect_from_buffer( int struct_dissect_from_buffer(
...@@ -37,15 +38,15 @@ int struct_dissect_from_buffer( ...@@ -37,15 +38,15 @@ int struct_dissect_from_buffer(
if ((strcmp (name, "IttiMsgText_s") == 0) && if ((strcmp (name, "IttiMsgText_s") == 0) &&
(type->members_child[0] != NULL) && (strcmp (type->members_child[0]->name, "size") == 0) && (type->members_child[0] != NULL) && (strcmp (type->members_child[0]->name, "size") == 0) &&
(type->members_child[1] != NULL) && (strcmp (type->members_child[1]->name, "text") == 0)) (type->members_child[1] != NULL) && (strcmp (type->members_child[1]->name, "text") == 0)) {
{
uint8_t *buf; uint8_t *buf;
length = buffer_get_uint32_t (buffer, offset + parent_offset); length = buffer_get_uint32_t (buffer, offset + parent_offset);
buf = malloc (length + 1); buf = malloc (length + 1);
buf[0] = '\n'; buf[0] = '\n';
buffer_fetch_nbytes(buffer, parent_offset + offset + 32, length, &buf[1]); buffer_fetch_nbytes(buffer, parent_offset + offset + 32, length, &buf[1]);
ui_set_signal_text_cb(user_data, (gchar *) buf, length); length = ui_callback_check_string ((char *) &buf[1], length, 0);
ui_set_signal_text_cb(user_data, (char *) buf, length + 1);
} }
else else
{ {
......
...@@ -160,6 +160,29 @@ gboolean ui_callback_on_about(GtkWidget *widget, gpointer data) ...@@ -160,6 +160,29 @@ gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
return TRUE; return TRUE;
} }
gint ui_callback_check_string (const char *string, const gint lenght, const guint message_number)
{
gint real_length;
real_length = strnlen (string, lenght);
if (lenght != real_length)
{
if (message_number)
{
g_warning("Bad string format for message %u, '\\0' found before end of string (%d/%d)\n", message_number, real_length, lenght);
}
else
{
g_warning("Bad string format, '\\0' found before end of string (%d/%d)\n", real_length, lenght);
}
return (real_length);
}
else
{
return (lenght);
}
}
gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path,
gboolean path_currently_selected, gpointer user_data) gboolean path_currently_selected, gpointer user_data)
{ {
...@@ -325,6 +348,7 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel ...@@ -325,6 +348,7 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
message_header_type_size = get_message_header_type_size (); message_header_type_size = get_message_header_type_size ();
data = (gchar *) buffer_at_offset ((buffer_t*) buffer, message_header_type_size); data = (gchar *) buffer_at_offset ((buffer_t*) buffer, message_header_type_size);
data_size = get_message_size ((buffer_t*) buffer); data_size = get_message_size ((buffer_t*) buffer);
data_size = ui_callback_check_string (data, data_size, message_number);
g_info(" dump message %d: header type size: %u, data size: %u, buffer %p, follow last %d", g_info(" dump message %d: header type size: %u, data size: %u, buffer %p, follow last %d",
message_number, message_header_type_size, data_size, buffer, ui_main_data.follow_last); message_number, message_header_type_size, data_size, buffer, ui_main_data.follow_last);
...@@ -446,7 +470,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ...@@ -446,7 +470,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data)
message_header_type_size = get_message_header_type_size (); message_header_type_size = get_message_header_type_size ();
string_terminal = (gchar *) buffer_at_offset ((buffer_t*) signal_buffer, message_header_type_size); string_terminal = (gchar *) buffer_at_offset ((buffer_t*) signal_buffer, message_header_type_size);
string_terminal_size = get_message_size ((buffer_t*) signal_buffer); string_terminal_size = get_message_size ((buffer_t*) signal_buffer);
string_terminal_size = ui_callback_check_string (string_terminal, string_terminal_size, signal_buffer->message_number);
ui_notebook_terminal_append_data(string_terminal, string_terminal_size); ui_notebook_terminal_append_data(string_terminal, string_terminal_size);
} }
......
...@@ -24,8 +24,9 @@ gboolean ui_callback_on_enable_filters(GtkWidget *widget, ...@@ -24,8 +24,9 @@ gboolean ui_callback_on_enable_filters(GtkWidget *widget,
gboolean ui_callback_on_about(GtkWidget *widget, gboolean ui_callback_on_about(GtkWidget *widget,
gpointer data); gpointer data);
void ui_signal_add_to_list(gpointer data, gint ui_callback_check_string (const char *string,
gpointer user_data); const gint lenght,
const guint message_number);
gboolean ui_callback_on_connect(GtkWidget *widget, gboolean ui_callback_on_connect(GtkWidget *widget,
gpointer data); gpointer data);
...@@ -43,6 +44,9 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, ...@@ -43,6 +44,9 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection,
gboolean path_currently_selected, gboolean path_currently_selected,
gpointer userdata); gpointer userdata);
void ui_signal_add_to_list(gpointer data,
gpointer user_data);
gboolean ui_callback_on_menu_enable (GtkWidget *widget, gpointer data); gboolean ui_callback_on_menu_enable (GtkWidget *widget, gpointer data);
gboolean ui_callback_on_menu_color (GtkWidget *widget, gpointer data); gboolean ui_callback_on_menu_color (GtkWidget *widget, gpointer data);
......
...@@ -21,7 +21,7 @@ int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *tit ...@@ -21,7 +21,7 @@ int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *tit
g_warning("%s", buffer); g_warning("%s", buffer);
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type, dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, type,
cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, "%s", cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, "%s",
buffer); buffer);
gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment