[PD-dev] dumpOSC crashes with long messages

Frank Barknecht fbar at footils.org
Thu Sep 15 00:25:20 CEST 2005


Hi,

a friend brought to my attention, that dumpOSC doesn't handle lists
with more than 50 elements properly. It simply crahes Pd. Attached
patch shows this. (pd 0.39 required for "list").

The reason actually is quite simple: dumpOSC.c defines a maximum of
atoms to hold in x->x_outat of being 50 as default, but later doesn't
check at all, if this space is exceeded. Here's the relevant part of
the struct declaration: 

/* ----------------------------- dumpOSC ------------------------- */

#define MAXOUTAT 20

static t_class *dumpOSC_class;

typedef struct _dumpOSC
{
  t_object x_obj;
  t_outlet *x_msgout;
  t_outlet *x_connectout;
  t_atom x_outat[MAXOUTAT];
  int x_outatc;
  /* ...  */
} t_dumpOSC;

Then later in the functions "dumpOSC_PrintTypeTaggedArgs" and
"dumpOSC_PrintHeuristicallyTypeGuessedArgs" x->x_outat is happily
filled with atoms as long as the incoming message list lasts, which of
course is a recipe for desaster. 

Now with my limited experience in C coding, I wonder, what's the best
way to fix this. 

I already wrapped all tries to append to x->x_outat in a big "if"
clause which checks, if MAXOUTAT is reached. This works and keeps Pd
from crashing. However somehow it doesn't feel right to just truncate
the incoming message, even when posting a big warning message. OTOH I
suppose, that declaring *x_outat with a fixed size was done for speed
reasons. Having to allocate memory everytime a message comes in would
be very slow.

Maybe one could introduce an argument to dumpOSC which sets the
maximum allowed message length (with a default of 50)? 

So what to do about this? Any advice or opinions? (Apart from using
liblo and totally rewriting OSCx, which of course probably is the best
solution ...) 

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
#N canvas 357 271 553 409 10;
#X obj 227 254 list trim;
#X obj 225 230 list append;
#X obj 225 288 sendOSC;
#X msg 305 262 connect localhost 3000;
#X obj 307 162 list prepend;
#X obj 399 162 list;
#X obj 310 116 until;
#X obj 303 136 f 0;
#X obj 344 137 + 1;
#X obj 114 213 print;
#X floatatom 338 71 5 0 0 0 - - -;
#X obj 333 222 loadbang;
#X msg 360 115 0;
#X obj 310 95 t f b;
#X msg 227 205 send /osc;
#X obj 227 65 t b b;
#X msg 227 43 CRASH ME;
#X obj 114 177 dumpOSC 3000;
#X msg 292 69 51;
#X connect 0 0 2 0;
#X connect 1 0 0 0;
#X connect 3 0 2 0;
#X connect 4 0 5 0;
#X connect 4 0 1 1;
#X connect 5 0 4 1;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 7 0 4 0;
#X connect 8 0 7 1;
#X connect 10 0 13 0;
#X connect 11 0 3 0;
#X connect 12 0 7 1;
#X connect 13 0 6 0;
#X connect 13 1 12 0;
#X connect 13 1 4 1;
#X connect 14 0 1 0;
#X connect 15 0 14 0;
#X connect 15 1 18 0;
#X connect 16 0 15 0;
#X connect 17 0 9 0;
#X connect 18 0 13 0;


More information about the Pd-dev mailing list