From: Daniel Carl Date: Sun, 14 Apr 2013 18:15:34 +0000 (+0200) Subject: Fixed segmentation fault in command history. X-Git-Url: https://git.owens.tech/wrapped.html/wrapped.html/git?a=commitdiff_plain;h=cdf7389ab3c4876a2701d79bffc0451e60958b2d;p=vimb.git Fixed segmentation fault in command history. If the history contained any item with printf placeholders like %s we got a segmentation fault if we print the value to the user. This patch use a dedicated format string for all user generated contents to be shown with vb_echo and vb_echo_force. --- diff --git a/src/command.c b/src/command.c index fa5ee77..cdfb389 100644 --- a/src/command.c +++ b/src/command.c @@ -247,10 +247,10 @@ gboolean command_input(const Arg *arg) ) { /* append the current url to the input message */ char *input = g_strconcat(arg->s, url, NULL); - vb_echo_force(VB_MSG_NORMAL, false, input); + vb_echo_force(VB_MSG_NORMAL, false, "%s", input); g_free(input); } else { - vb_echo_force(VB_MSG_NORMAL, false, arg->s); + vb_echo_force(VB_MSG_NORMAL, false, "%s", arg->s); } vb_set_mode(VB_MODE_COMMAND, false); @@ -415,7 +415,7 @@ gboolean command_inspect(const Arg *arg) gboolean command_hints(const Arg *arg) { - vb_echo_force(VB_MSG_NORMAL, false, arg->s); + vb_echo_force(VB_MSG_NORMAL, false, "%s", arg->s); /* mode will be set in hints_create - so we don't neet to do it here */ hints_create(NULL, arg->i, (arg->s ? strlen(arg->s) : 0)); @@ -597,7 +597,7 @@ gboolean command_history(const Arg *arg) return false; } - vb_echo_force(VB_MSG_NORMAL, false, entry); + vb_echo_force(VB_MSG_NORMAL, false, "%s", entry); g_free(entry); return true; @@ -619,9 +619,9 @@ gboolean command_eval(const Arg *arg) webkit_web_view_get_main_frame(vb.gui.webview), arg->s, NULL, &value ); if (success) { - vb_echo_force(VB_MSG_NORMAL, false, value); + vb_echo_force(VB_MSG_NORMAL, false, "%s", value); } else { - vb_echo_force(VB_MSG_ERROR, true, value); + vb_echo_force(VB_MSG_ERROR, true, "%s", value); } g_free(value); vb_set_mode(VB_MODE_NORMAL, false); diff --git a/src/main.c b/src/main.c index bfa2683..cb0e14a 100644 --- a/src/main.c +++ b/src/main.c @@ -74,7 +74,7 @@ static void set_status(const StatusType status); void inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message); static void destroy_client(); -void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...) +void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...) { char message[255]; va_list arg_list;