[Pkg-xfce-commits] r2580 - in goodies/xfce4-mpc-plugin/debian: . patches
huggie at alioth.debian.org
huggie at alioth.debian.org
Sat Jan 3 14:22:19 UTC 2009
Author: huggie
Date: 2009-01-03 14:22:19 +0000 (Sat, 03 Jan 2009)
New Revision: 2580
Added:
goodies/xfce4-mpc-plugin/debian/patches/
goodies/xfce4-mpc-plugin/debian/patches/01_fix_buffer_overflows.diff
Modified:
goodies/xfce4-mpc-plugin/debian/changelog
goodies/xfce4-mpc-plugin/debian/rules
Log:
Fix up xfce4-mpc-plugin for buffer overflows on password and potential
others and don't use sprintf to concat strings.
Modified: goodies/xfce4-mpc-plugin/debian/changelog
===================================================================
--- goodies/xfce4-mpc-plugin/debian/changelog 2009-01-03 00:47:25 UTC (rev 2579)
+++ goodies/xfce4-mpc-plugin/debian/changelog 2009-01-03 14:22:19 UTC (rev 2580)
@@ -1,3 +1,10 @@
+xfce4-mpc-plugin (0.3.3-2) unstable; urgency=low
+
+ * Patch for buffer overflow in numerous places and also replace
+ snprintf(foo, "%s...", foo, ...) pattern. closes: #498770
+
+ -- Simon Huggins <huggie at earth.li> Sat, 03 Jan 2009 13:51:45 +0000
+
xfce4-mpc-plugin (0.3.3-1) unstable; urgency=low
[ Simon Huggins ]
Added: goodies/xfce4-mpc-plugin/debian/patches/01_fix_buffer_overflows.diff
===================================================================
--- goodies/xfce4-mpc-plugin/debian/patches/01_fix_buffer_overflows.diff (rev 0)
+++ goodies/xfce4-mpc-plugin/debian/patches/01_fix_buffer_overflows.diff 2009-01-03 14:22:19 UTC (rev 2580)
@@ -0,0 +1,208 @@
+diff -x host -urN xfce4-mpc-plugin-0.3.3/panel-plugin/simple-libmpd.c xfce4-mpc-plugin-0.3.3.patched/panel-plugin/simple-libmpd.c
+--- xfce4-mpc-plugin-0.3.3/panel-plugin/simple-libmpd.c 2008-03-24 19:17:52.000000000 +0000
++++ xfce4-mpc-plugin-0.3.3.patched/panel-plugin/simple-libmpd.c 2008-12-08 23:00:35.000000000 +0000
+@@ -37,17 +37,15 @@
+ #include <errno.h>
+ #include <fcntl.h>
+
+-#define STRLENGTH 32
+-
+ MpdObj* mpd_new(char* host, int port, char* pass)
+ {
+ MpdObj* mo = g_new0(MpdObj,1);
+
+ DBG("host=%s, port=%d, pass=%s", host, port, pass);
+
+- mo->host = g_strndup(host,STRLENGTH);
++ mo->host = g_strdup(host);
+ mo->port = port;
+- mo->pass = g_strndup(pass,STRLENGTH);
++ mo->pass = g_strdup(pass);
+ mo->socket = 0;
+ mo->status = 0;
+ mo->repeat = 0;
+@@ -508,7 +506,7 @@
+ char outbuf[15];
+ /* write setvol 'newvol' to socket */
+ DBG("!");
+- sprintf(outbuf,"setvol %d\n",newvol);
++ snprintf(outbuf, sizeof(outbuf), "setvol %d\n",newvol);
+ mpd_send_single_cmd(mo,outbuf);
+ }
+
+@@ -528,7 +526,7 @@
+ {
+ char outbuf[15];
+ DBG("!");
+- sprintf(outbuf,"random %d\n",random);
++ snprintf(outbuf, sizeof(outbuf), "random %d\n",random);
+ return mpd_send_single_cmd(mo,outbuf);
+
+ }
+@@ -537,7 +535,7 @@
+ {
+ char outbuf[15];
+ DBG("!");
+- sprintf(outbuf,"repeat %d\n",repeat);
++ snprintf(outbuf, sizeof(outbuf), "repeat %d\n",repeat);
+ return mpd_send_single_cmd(mo,outbuf);
+ }
+
+@@ -584,7 +582,7 @@
+ {
+ char outbuf[15];
+ DBG("!");
+- sprintf(outbuf,"playid %d\n",id);
++ snprintf(outbuf, sizeof(outbuf), "playid %d\n",id);
+ return mpd_send_single_cmd(mo,outbuf);
+ }
+
+@@ -597,9 +595,16 @@
+ void mpd_send_password(MpdObj* mo)
+ {
+ DBG("!");
+- char outbuf[30];
++ char outbuf[256];
+ /* write password 'password' to socket */
+- sprintf(outbuf,"password %s\n",mo->pass);
++ int wrote = snprintf(outbuf, sizeof(outbuf), "password %s\n",mo->pass);
++ if (wrote > 255) {
++ /* the password is too long to fit though there doesn't seem to be a
++ * nice way to report this error :-/ */
++ fprintf(stderr, "xfce4-mpc-plugin: password too long!\n");
++ mo->error = MPD_ERROR_SYSTEM;
++ return;
++ }
+ mpd_send_single_cmd(mo,outbuf);
+ }
+
+@@ -607,14 +612,14 @@
+ {
+ DBG("! new hostname=%s",host);
+ g_free(mo->host);
+- mo->host = g_strndup(host,STRLENGTH);
++ mo->host = g_strdup(host);
+ }
+
+ void mpd_set_password(MpdObj* mo, char* pass)
+ {
+ DBG("! new password=%s",pass);
+ g_free(mo->pass);
+- mo->pass = g_strndup(pass,STRLENGTH);
++ mo->pass = g_strdup(pass);
+ }
+
+ void mpd_set_port(MpdObj* mo,int port)
+diff -x host -urN xfce4-mpc-plugin-0.3.3/panel-plugin/xfce4-mpc-plugin.c xfce4-mpc-plugin-0.3.3.patched/panel-plugin/xfce4-mpc-plugin.c
+--- xfce4-mpc-plugin-0.3.3/panel-plugin/xfce4-mpc-plugin.c 2008-03-24 19:17:52.000000000 +0000
++++ xfce4-mpc-plugin-0.3.3.patched/panel-plugin/xfce4-mpc-plugin.c 2009-01-03 13:43:44.000000000 +0000
+@@ -29,7 +29,6 @@
+ #define DEFAULT_MPD_HOST "localhost"
+ #define DEFAULT_MPD_PORT 6600
+ #define DIALOG_ENTRY_WIDTH 15
+-#define STRLENGTH 32
+
+ #include "xfce4-mpc-plugin.h"
+
+@@ -107,7 +106,7 @@
+ mpc->show_frame = xfce_rc_read_bool_entry (rc, "show_frame", TRUE);
+ mpc->client_appl = g_strdup(xfce_rc_read_entry (rc, "client_appl", ""));
+ label = gtk_bin_get_child(GTK_BIN(mpc->appl));
+- g_sprintf(str, "%s %s", _("Launch"), mpc->client_appl);
++ g_snprintf(str, sizeof(str), "%s %s", _("Launch"), mpc->client_appl);
+ gtk_label_set_text(GTK_LABEL(label),str);
+ DBG ("Settings : %s@%s:%d\nframe:%d\nappl:%s", mpc->mpd_password, mpc->mpd_host, mpc->mpd_port, mpc->show_frame, mpc->client_appl);
+ xfce_rc_close (rc);
+@@ -165,12 +164,12 @@
+ char str[30];
+
+ t_mpc *mpc = dialog->mpc;
+- mpc->mpd_host = g_strndup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_host)),STRLENGTH);
++ mpc->mpd_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_host)));
+ mpc->mpd_port = atoi(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_port)));
+- mpc->mpd_password = g_strndup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_password)),STRLENGTH);
+- mpc->client_appl = g_strndup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_client_appl)),STRLENGTH);
++ mpc->mpd_password = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_password)));
++ mpc->client_appl = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->textbox_client_appl)));
+ label = gtk_bin_get_child(GTK_BIN(mpc->appl));
+- g_sprintf(str, "%s %s", _("Launch"), mpc->client_appl);
++ g_snprintf(str, sizeof(str), "%s %s", _("Launch"), mpc->client_appl);
+ gtk_label_set_text(GTK_LABEL(label),str);
+
+ DBG ("Apply: host=%s, port=%d, passwd=%s, appl=%s", mpc->mpd_host, mpc->mpd_port, mpc->mpd_password, mpc->client_appl);
+@@ -307,17 +306,22 @@
+ }
+
+ void
+-format_song_display(mpd_Song* song, gchar* str)
++format_song_display(mpd_Song* song, gchar* str, int size)
+ {
++ char tmp[256];
+ /* buf may contain stuff, care to append text */
+ if (!song->artist || !song->title)
+- g_sprintf(str,"%s%s", str, song->file);
+- else if (!song->album)
+- g_sprintf(str,"%s%s - %s", str, song->artist, song->title);
+- else if (!song->track)
+- g_sprintf(str,"%s%s - %s -/- %s", str, song->artist, song->album, song->title);
+- else
+- g_sprintf(str,"%s%s - %s -/- (#%s) %s", str, song->artist, song->album, song->track, song->title);
++ g_strlcat(str, song->file, size);
++ else if (!song->album) {
++ g_snprintf(tmp, 255, "%s - %s", song->artist, song->title);
++ g_strlcat(str, tmp, size);
++ } else if (!song->track) {
++ g_snprintf(tmp, 255, "%s - %s -/- %s", song->artist, song->album, song->title);
++ g_strlcat(str, tmp, size);
++ } else {
++ g_snprintf(tmp, 255, "%s - %s -/- (#%s) %s", song->artist, song->album, song->track, song->title);
++ g_strlcat(str, tmp, size);
++ }
+ }
+
+ static void
+@@ -337,28 +341,28 @@
+ }
+ }
+
+- g_sprintf(str, "Volume : %d%%", mpd_status_get_volume(mpc->mo));
++ g_snprintf(str, sizeof(str), "Volume : %d%%", mpd_status_get_volume(mpc->mo));
+
+ switch (mpd_player_get_state(mpc->mo))
+ {
+ case MPD_PLAYER_PLAY:
+- g_sprintf(str, "%s - Mpd Playing\n",str);
++ g_strlcat(str, " - Mpd Playing\n", sizeof(str));
+ break;
+ case MPD_PLAYER_PAUSE:
+- g_sprintf(str, "%s - Mpd Paused\n",str);
++ g_strlcat(str, " - Mpd Paused\n", sizeof(str));
+ break;
+ case MPD_PLAYER_STOP:
+- g_sprintf(str, "%s - Mpd Stopped\n",str);
++ g_strlcat(str, " - Mpd Stopped\n", sizeof(str));
+ break;
+ default:
+- g_sprintf(str, "%s - Mpd state ?\n",str);
++ g_strlcat(str, " - Mpd state ?\n", sizeof(str));
+ break;
+ }
+ song = mpd_playlist_get_current_song(mpc->mo);
+ if (song && song->id != -1)
+- format_song_display(song, str);
++ format_song_display(song, str, sizeof(str));
+ else
+- g_sprintf(str,"%sFailed to get song info ?", str);
++ g_strlcat(str, "Failed to get song info ?", sizeof(str));
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mpc->random), mpd_player_get_random(mpc->mo));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mpc->repeat), mpd_player_get_repeat(mpc->mo));
+@@ -440,7 +444,7 @@
+ do
+ {
+ str[0]='\0';
+- format_song_display(mpd_data->song, str);
++ format_song_display(mpd_data->song, str, sizeof(str));
+
+ gtk_list_store_append (liststore, &iter);
+ if (current == mpd_data->song->pos)
Modified: goodies/xfce4-mpc-plugin/debian/rules
===================================================================
--- goodies/xfce4-mpc-plugin/debian/rules 2009-01-03 00:47:25 UTC (rev 2579)
+++ goodies/xfce4-mpc-plugin/debian/rules 2009-01-03 14:22:19 UTC (rev 2580)
@@ -1,5 +1,6 @@
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
DEB_CONFIGURE_EXTRA_FLAGS := --disable-libmpd
More information about the Pkg-xfce-commits
mailing list