#! /bin/sh /usr/share/dpatch/dpatch-run
## 51_fix-format-strings.dpatch by Kees Cook <kees@ubuntu.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad ekiga-2.0.3~/lib/gui/gmstatusbar.c ekiga-2.0.3/lib/gui/gmstatusbar.c
--- ekiga-2.0.3~/lib/gui/gmstatusbar.c	2006-03-12 07:46:42.000000000 -0800
+++ ekiga-2.0.3/lib/gui/gmstatusbar.c	2007-03-06 15:07:46.259844335 -0800
@@ -48,7 +48,7 @@
 				gboolean,
 				gboolean,
 				const char *, 
-				...);
+				va_list args);
 
 static int  gm_statusbar_clear_msg_cb (gpointer);
 
@@ -100,7 +100,7 @@
 		    gboolean flash_message,
 		    gboolean info_message,
 		    const char *msg, 
-		    ...)
+		    va_list args)
 {
   gint id = 0;
   gint msg_id = 0;
@@ -119,17 +119,12 @@
     gtk_statusbar_pop (GTK_STATUSBAR (sb), id);
 
   if (msg) {
-
-    va_list args;
     char buffer [1025];
 
-    va_start (args, msg);
     vsnprintf (buffer, 1024, msg, args);
 
     msg_id = gtk_statusbar_push (GTK_STATUSBAR (sb), id, buffer);
 
-    va_end (args);
-
     if (flash_message)
       gtk_timeout_add (15000, gm_statusbar_clear_msg_cb, 
 		       GINT_TO_POINTER (msg_id));
diff -urNad ekiga-2.0.3~/src/endpoints/accountshandler.cpp ekiga-2.0.3/src/endpoints/accountshandler.cpp
--- ekiga-2.0.3~/src/endpoints/accountshandler.cpp	2006-05-13 10:32:49.000000000 -0700
+++ ekiga-2.0.3/src/endpoints/accountshandler.cpp	2007-03-06 15:04:00.144368243 -0800
@@ -202,8 +202,8 @@
 			     a->host?a->host:"");
 
       gnomemeeting_threads_enter ();
-      gm_main_window_push_message (main_window, msg);
-      gm_history_window_insert (history_window, msg);
+      gm_main_window_push_message (main_window, "%s", msg);
+      gm_history_window_insert (history_window, "%s", msg);
       gm_accounts_window_update_account_state (accounts_window,
 					       FALSE,
 					       a->host,
@@ -312,8 +312,8 @@
       msg = g_strdup_printf (_("Registered to %s"), a->host);
 
     gnomemeeting_threads_enter ();
-    gm_main_window_push_message (main_window, msg);
-    gm_history_window_insert (history_window, msg);
+    gm_main_window_push_message (main_window, "%s", msg);
+    gm_history_window_insert (history_window, "%s", msg);
     gm_accounts_window_update_account_state (accounts_window,
 					     FALSE,
 					     a->host,
@@ -343,8 +343,8 @@
     h323EP->RemoveAliasName (a->username);
 
     gnomemeeting_threads_enter ();
-    gm_main_window_push_message (main_window, msg);
-    gm_history_window_insert (history_window, msg);
+    gm_main_window_push_message (main_window, "%s", msg);
+    gm_history_window_insert (history_window, "%s", msg);
     gm_accounts_window_update_account_state (accounts_window,
 					     FALSE,
 					     a->host,
diff -urNad ekiga-2.0.3~/src/endpoints/manager.cpp ekiga-2.0.3/src/endpoints/manager.cpp
--- ekiga-2.0.3~/src/endpoints/manager.cpp	2006-08-29 12:23:34.000000000 -0700
+++ ekiga-2.0.3/src/endpoints/manager.cpp	2007-03-06 15:04:00.144368243 -0800
@@ -660,8 +660,8 @@
   gnomemeeting_threads_enter ();
   msg = g_strdup_printf (_("Forwarding call to %s"),
 			 (const char*) forward_party);
-  gm_main_window_flash_message (main_window, msg);
-  gm_history_window_insert (history_window, msg);
+  gm_main_window_flash_message (main_window, "%s", msg);
+  gm_history_window_insert (history_window, "%s", msg);
   gnomemeeting_threads_leave ();
   g_free (msg);
 
@@ -814,9 +814,9 @@
   /* Update the log and status bar */
   msg = g_strdup_printf (_("Call from %s"), (const char *) utf8_name);
   gnomemeeting_threads_enter ();
-  gm_main_window_flash_message (main_window, msg);
-  gm_chat_window_push_info_message (chat_window, NULL, msg);
-  gm_history_window_insert (history_window, msg);
+  gm_main_window_flash_message (main_window, "%s", msg);
+  gm_chat_window_push_info_message (chat_window, NULL, "%s", msg);
+  gm_history_window_insert (history_window, "%s", msg);
   gnomemeeting_threads_leave ();
   g_free (msg);
 
@@ -854,9 +854,9 @@
   /* Display the action message */
   gnomemeeting_threads_enter ();
   if (short_reason) 
-    gm_main_window_flash_message (main_window, short_reason);
+    gm_main_window_flash_message (main_window, "%s", short_reason);
   if (long_reason)
-    gm_history_window_insert (history_window, long_reason);
+    gm_history_window_insert (history_window, "%s", long_reason);
   gnomemeeting_threads_leave ();
   
   /* Update the current state if action is 0 or 4.
@@ -1001,8 +1001,8 @@
 			      utf8_name, utf8_app);
   msg = g_strdup_printf (_("Connected with %s"), utf8_name);
   gm_main_window_set_status (main_window, msg);
-  gm_main_window_flash_message (main_window, msg);
-  gm_chat_window_push_info_message (chat_window, NULL, msg);
+  gm_main_window_flash_message (main_window, "%s", msg);
+  gm_chat_window_push_info_message (chat_window, NULL, "%s", msg);
   gm_main_window_update_calling_state (main_window, GMManager::Connected);
   gm_chat_window_update_calling_state (chat_window, 
 				       utf8_name,
@@ -1272,11 +1272,11 @@
 				 t.AsString (0),
 				 msg_reason,
 				 utf8_app);
-  gm_history_window_insert (history_window, msg_reason);
+  gm_history_window_insert (history_window, "%s", msg_reason);
   gm_main_window_push_message (main_window, 
 			       GetMissedCallsNumber (), 
 			       GetMWI ());
-  gm_main_window_flash_message (main_window, msg_reason);
+  gm_main_window_flash_message (main_window, "%s", msg_reason);
   gm_chat_window_push_info_message (chat_window, NULL, "");
   gnomemeeting_threads_leave ();
 
@@ -1902,7 +1902,7 @@
 
   /* Update the GUI and menus wrt opened channels */
   gnomemeeting_threads_enter ();
-  gm_history_window_insert (history_window, msg);
+  gm_history_window_insert (history_window, "%s", msg);
   gm_main_window_update_sensitivity (main_window, is_video, is_video?is_receiving_video:is_receiving_audio, is_video?is_transmitting_video:is_transmitting_audio);
   gm_main_window_set_channel_pause (main_window, FALSE, is_video);
   gm_main_window_set_call_info (main_window, 
@@ -2058,7 +2058,7 @@
 
 
   gdk_threads_enter ();
-  gm_main_window_push_info_message (main_window, msg);
+  gm_main_window_push_info_message (main_window, "%s", msg);
   gm_main_window_update_stats (main_window,
 			       lost_packets_per,
 			       late_packets_per,
diff -urNad ekiga-2.0.3~/src/endpoints/sip.cpp ekiga-2.0.3/src/endpoints/sip.cpp
--- ekiga-2.0.3~/src/endpoints/sip.cpp	2006-06-15 14:08:42.000000000 -0700
+++ ekiga-2.0.3/src/endpoints/sip.cpp	2007-03-06 15:04:00.144368243 -0800
@@ -226,8 +226,8 @@
 						    wasRegistering);
 #endif
 
-  gm_history_window_insert (history_window, msg);
-  gm_main_window_flash_message (main_window, msg);
+  gm_history_window_insert (history_window, "%s", msg);
+  gm_main_window_flash_message (main_window, "%s", msg);
   if (endpoint.GetCallingState() == GMManager::Standby)
     gm_main_window_set_account_info (main_window, 
 				     endpoint.GetRegisteredAccounts());
@@ -319,8 +319,8 @@
 					     NULL);
   }
 
-  gm_history_window_insert (history_window, msg);
-  gm_main_window_push_message (main_window, msg);
+  gm_history_window_insert (history_window, "%s", msg);
+  gm_main_window_push_message (main_window, "%s", msg);
   gnomemeeting_threads_leave ();
 
   /* Signal the SIP Endpoint */
diff -urNad ekiga-2.0.3~/src/endpoints/urlhandler.cpp ekiga-2.0.3/src/endpoints/urlhandler.cpp
--- ekiga-2.0.3~/src/endpoints/urlhandler.cpp	2006-05-17 13:32:32.000000000 -0700
+++ ekiga-2.0.3/src/endpoints/urlhandler.cpp	2007-03-06 15:04:00.148368446 -0800
@@ -471,8 +471,8 @@
     else
       msg = g_strdup_printf (_("Transferring call to %s"), 
 			     (const char *) call_address);
-    gm_history_window_insert (history_window, msg);
-    gm_main_window_push_message (main_window, msg);
+    gm_history_window_insert (history_window, "%s", msg);
+    gm_main_window_push_message (main_window, "%s", msg);
     g_free (msg);
   }
   gnomemeeting_threads_leave ();
@@ -527,7 +527,7 @@
 
       if (call_address.Find ("+type=directory") != P_MAX_INDEX) {
 
-	gm_main_window_flash_message (main_window, _("User not found"));
+	gm_main_window_flash_message (main_window, "%s", _("User not found"));
 	gm_calls_history_add_call (PLACED_CALL,
 				   NULL,
 				   call_address, 
@@ -538,7 +538,7 @@
       }
       else {
 	
-	gm_main_window_flash_message (main_window, _("Failed to call user"));
+	gm_main_window_flash_message (main_window, "%s", _("Failed to call user"));
 	gm_calls_history_add_call (PLACED_CALL,
 				   NULL,
 				   call_address, 
diff -urNad ekiga-2.0.3~/src/gui/chat.cpp ekiga-2.0.3/src/gui/chat.cpp
--- ekiga-2.0.3~/src/gui/chat.cpp	2006-05-06 13:02:31.000000000 -0700
+++ ekiga-2.0.3/src/gui/chat.cpp	2007-03-06 15:10:49.025119818 -0800
@@ -1684,10 +1684,12 @@
   va_list args;
 
   va_start (args, msg);
+  char *buffer = g_strdup_vprintf(msg, args);
 
   contact_url = gtk_entry_get_text (GTK_ENTRY (twp->remote_url));
   
   if (!url || GMURL (contact_url) == GMURL (url))
-    gm_statusbar_push_info_message (GM_STATUSBAR (tw->statusbar), msg, args);
+    gm_statusbar_push_info_message (GM_STATUSBAR (tw->statusbar), "%s", buffer);
+  g_free (buffer);
   va_end (args);
 }
diff -urNad ekiga-2.0.3~/src/gui/main.cpp ekiga-2.0.3/src/gui/main.cpp
--- ekiga-2.0.3~/src/gui/main.cpp	2007-03-06 15:03:59.824352001 -0800
+++ ekiga-2.0.3/src/gui/main.cpp	2007-03-06 15:12:00.900767458 -0800
@@ -2304,7 +2304,7 @@
   info = g_strdup_printf (_("Missed calls: %d - Voice Mails: %s"),
 			  ep->GetMissedCallsNumber (),
 			  (const char *) ep->GetMWI ());
-  gm_main_window_push_info_message (GTK_WIDGET (data), info);
+  gm_main_window_push_info_message (GTK_WIDGET (data), "%s", info);
   g_free (info);
 
 
@@ -4240,7 +4240,7 @@
 {
   GmWindow *mw = NULL;
 
-  char buffer [1025];
+  char *buffer;
 
   g_return_if_fail (main_window != NULL);
 
@@ -4249,9 +4249,10 @@
   va_list args;
 
   va_start (args, msg);
-  vsnprintf (buffer, 1024, msg, args);
-  gm_statusbar_flash_message (GM_STATUSBAR (mw->statusbar), buffer);
+  buffer = g_strdup_vprintf (msg, args);
+  gm_statusbar_flash_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
   va_end (args);
+  g_free (buffer);
 }
 
 
@@ -4270,7 +4271,7 @@
   mw = gm_mw_get_mw (main_window);
   
   info = g_strdup_printf (_("Missed calls: %d - Voice Mails: %s"), missed, vm);
-  gm_main_window_push_info_message (main_window, info);
+  gm_main_window_push_info_message (main_window, "%s", info);
 
   g_free (info);
 }
@@ -4293,7 +4294,7 @@
 
   va_start (args, msg);
   vsnprintf (buffer, 1024, msg, args);
-  gm_statusbar_push_message (GM_STATUSBAR (mw->statusbar), buffer);
+  gm_statusbar_push_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
   va_end (args);
 }
 
@@ -4305,6 +4306,8 @@
 {
   GmWindow *mw = NULL;
   
+  char buffer [1025];
+
   g_return_if_fail (main_window != NULL);
 
   mw = gm_mw_get_mw (main_window);
@@ -4312,7 +4315,8 @@
   va_list args;
 
   va_start (args, msg);
-  gm_statusbar_push_info_message (GM_STATUSBAR (mw->statusbar), msg, args);
+  vsnprintf (buffer, 1024, msg, args);
+  gm_statusbar_push_info_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
   va_end (args);
 }
 
