commit 3c23d503b319f9b03da689631e1e49bc13b7c435
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Tue Jan 18 22:48:42 2011 +0000

    Fix for potential segfaults due to '%' in message strings
    
    * Should hopefully stop any messages containing a % symbol such as that used
      in urls for apostrophes (%27) from crashing the application

 libgtkpod/gtkpod_app_iface.c |    4 ++--
 libgtkpod/gtkpod_app_iface.h |    4 ++--
 src/anjuta-app.c             |   23 +++++++++++++++++++----
 3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/libgtkpod/gtkpod_app_iface.c b/libgtkpod/gtkpod_app_iface.c
index a3a9fe5..e5e66db 100644
--- a/libgtkpod/gtkpod_app_iface.c
+++ b/libgtkpod/gtkpod_app_iface.c
@@ -192,7 +192,7 @@ void gtkpod_statusbar_message(gchar* message, ...) {
     msg = g_strdup_vprintf(message, args);
     va_end (args);
 
-    GTKPOD_APP_GET_INTERFACE (gtkpod_app)->statusbar_message(gtkpod_app, msg);
+    GTKPOD_APP_GET_INTERFACE (gtkpod_app)->statusbar_message(gtkpod_app, "%s", 
msg);
     g_free(msg);
 }
 
@@ -234,7 +234,7 @@ void gtkpod_warning(gchar* message, ...) {
     msg = g_strdup_vprintf(message, args);
     va_end (args);
 
-    GTKPOD_APP_GET_INTERFACE (gtkpod_app)->gtkpod_warning(gtkpod_app, msg);
+    GTKPOD_APP_GET_INTERFACE (gtkpod_app)->gtkpod_warning(gtkpod_app, "%s", 
msg);
     g_free(msg);
 }
 
diff --git a/libgtkpod/gtkpod_app_iface.h b/libgtkpod/gtkpod_app_iface.h
index 2c5d8ca..ab6ddaa 100644
--- a/libgtkpod/gtkpod_app_iface.h
+++ b/libgtkpod/gtkpod_app_iface.h
@@ -142,8 +142,8 @@ struct _GtkPodAppInterface {
     GHashTable *filetypes;
 
     void (*itdb_updated)(GtkPodApp *obj, iTunesDB *oldItdb, iTunesDB *newItbd);
-    void (*statusbar_message)(GtkPodApp *obj, gchar* message);
-    void (*gtkpod_warning)(GtkPodApp *obj, gchar *message);
+    void (*statusbar_message)(GtkPodApp *obj, gchar* message, ...);
+    void (*gtkpod_warning)(GtkPodApp *obj, gchar *message, ...);
     void (*gtkpod_warning_hig)(GtkPodApp *obj, GtkMessageType icon, const 
gchar *primary_text, const gchar *secondary_text);
     gint
             (*gtkpod_confirmation_hig)(GtkPodApp *obj, GtkMessageType icon, 
const gchar *primary_text, const gchar *secondary_text, const gchar 
*accept_button_text, const gchar *cancel_button_text, const gchar 
*third_button_text, const gchar *help_context);
diff --git a/src/anjuta-app.c b/src/anjuta-app.c
index d43d725..4819af8 100644
--- a/src/anjuta-app.c
+++ b/src/anjuta-app.c
@@ -973,10 +973,18 @@ static void anjuta_shell_iface_init(AnjutaShellIface 
*iface) {
  * --       GtkPodAppInterface implementations                  --
  * -------------------------------------------------------------------------
  */
-static void anjuta_gtkpod_app_statusbar_message(GtkPodApp *gtkpod_app, gchar* 
message) {
+static void anjuta_gtkpod_app_statusbar_message(GtkPodApp *gtkpod_app, gchar* 
message, ...) {
     g_return_if_fail(ANJUTA_IS_APP(gtkpod_app));
+
+    gchar* msg;
+    va_list args;
+    va_start (args, message);
+    msg = g_strdup_vprintf(message, args);
+    va_end (args);
+
     AnjutaStatus *status = anjuta_shell_get_status(ANJUTA_SHELL(gtkpod_app), 
NULL);
-    anjuta_status_set(status, message);
+    anjuta_status_set(status, "%s", msg);
+    g_free(msg);
 }
 
 static void anjuta_gtkpod_app_statusbar_busy_push(GtkPodApp *gtkpod_app) {
@@ -991,9 +999,16 @@ static void anjuta_gtkpod_app_statusbar_busy_pop(GtkPodApp 
*gtkpod_app) {
     anjuta_status_busy_pop(status);
 }
 
-static void anjuta_gtkpod_app_warning(GtkPodApp *gtkpod_app, gchar *message) {
+static void anjuta_gtkpod_app_warning(GtkPodApp *gtkpod_app, gchar *message, 
...) {
     g_return_if_fail(GTK_IS_WINDOW(gtkpod_app));
-    anjuta_util_dialog_warning(GTK_WINDOW(gtkpod_app), message);
+    gchar* msg;
+    va_list args;
+    va_start (args, message);
+    msg = g_strdup_vprintf(message, args);
+    va_end (args);
+
+    anjuta_util_dialog_warning(GTK_WINDOW(gtkpod_app), "%s", msg);
+    g_free(msg);
 }
 
 static void anjuta_gtkpod_app_warning_hig(GtkPodApp *gtkpod_app, 
GtkMessageType icon, const gchar *primary_text, const gchar *secondary_text) {

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to