]> git.alsa-project.org Git - alsa-tools.git/commitdiff
hdspmixer: Fix buffer overflow
authorGeorg Rudolph <georg.rudolph@schwaben.de>
Sat, 15 May 2010 07:37:34 +0000 (09:37 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sat, 15 May 2010 10:00:27 +0000 (12:00 +0200)
A one off string buffer overflow fixed by handling it properly with
string stream.

Signed-off-by: Georg Rudolph <georg.rudolph@schwaben.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
hdspmixer/src/HDSPMixerIOMixer.cxx
hdspmixer/src/HDSPMixerIOMixer.h

index a431de5cd48a0f8b944a8cb993d3694e5d7412f1..a81f4a2905750fe0d3ec372d5262ca5537bfd4e0 100644 (file)
@@ -25,9 +25,9 @@ HDSPMixerIOMixer::HDSPMixerIOMixer(int x, int y, int w, int h, int ch, int type)
 {
     mixer_type = type;
     if (type) {
-       sprintf(channel_name, "Out %d", ch);
+       channel_name << "Out " << ch;
     } else {
-       sprintf(channel_name, "In %d", ch);
+       channel_name << "In " << ch;
     }
     channel_num = ch;
     if (channel_num%2) {
@@ -73,7 +73,7 @@ void HDSPMixerIOMixer::draw()
        draw_background();
        fl_color(FL_BLACK);
        fl_font(FL_HELVETICA, 8);
-       fl_draw(channel_name, x()+4, y()+225, 27, 9, FL_ALIGN_CENTER);
+       fl_draw(channel_name.str().c_str(), x()+4, y()+225, 27, 9, FL_ALIGN_CENTER);
        for (int i=children(); i--;) {
            Fl_Widget& o = **a++;
            draw_child(o);
index 6286daf143e004ab4f5473ef8fb1d2f06f8e4427..a9a35de5c7867fe60f39dc5570defdee39635e54 100644 (file)
@@ -36,6 +36,7 @@
 #include "HDSPMixerStripData.h"
 #include "HDSPMixerMeter.h"
 #include "pixmaps.h"
+#include <sstream>
 
 class HDSPMixerWindow;
 class HDSPMixerSelector;
@@ -52,7 +53,7 @@ class HDSPMixerIOMixer:public Fl_Group
 private:
     char **p_iomixer_xpm;
     int channel_num, relative_num, mixer_type;
-    char channel_name[6];
+       std::stringstream channel_name;
     void update_child(Fl_Widget &widget);
 public:
     HDSPMixerStripData *data[3][3][8]; /* data[card][mode(ss/ds/qs)][preset number] */