Re: [PD] [unpackOSC] wrong packet crash

2010-05-14 Thread patko

 I didn't pay attention about how things have changed,
for python modules loading, my bad.
 Please just put the attached __init__.py and 
fixed oscAPI.py in same folder for replacing malfunctioning files.



  I get:
  Traceback (most recent call last):
 File E:\martin\pd_patches\oscCRASH\oscCRASH\sendOSC.py, line 1,
  in
  module
   import osc
 File E:\martin\pd_patches\oscCRASH\oscCRASH\osc\__init__.py,
 line
 
  8, in module
   from OSC import *
  ImportError: No module named OSC
 
  Which OSC?
  Martin
 
 it should be OSC.py !?
 
 I didn't try on IDLE, maybe I should make a test...
 simpleOSC 0.2
ixi software - July, 2006
www.ixi-software.net

simple API  for the Open SoundControl for Python (by Daniel Holth, Clinton
McChesney -- pyKit.tar.gz file at http://wiretap.stetson.edu)
Documentation at http://wiretap.stetson.edu/docs/pyKit/

The main aim of this implementation is to provide with a simple way to deal
with the OSC implementation that makes life easier to those who don't have
understanding of sockets or programming. This would not be on your screen without the help
of Daniel Holth.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Thanks for the support to Buchsenhausen, Innsbruck, Austria.


import osc.OSC as OSC
import socket
from threading import Thread

# globals
outSocket = 0 
addressManager = 0 
oscThread = 0




def init() :
 instantiates address manager and outsocket as globals

global outSocket, addressManager
outSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addressManager = OSC.CallbackManager()


def bind(func, oscaddress):
 bind given oscaddresses with given functions in address manager

addressManager.add(func, oscaddress)


def sendMsg(oscAddress, dataArray=[], ipAddr='127.0.0.1', port=9000) :
create and send normal OSC msgs
defaults to '127.0.0.1', port 9000

outSocket.sendto( createBinaryMsg(oscAddress, dataArray),  (ipAddr, port))


def createBundle():
create bundled type of OSC messages

b = OSC.OSCMessage()
b.address = 
b.append(#bundle)
b.append(0)
b.append(0)
return b


def appendToBundle(bundle, oscAddress, dataArray):
create OSC mesage and append it to a given bundle

bundle.append( createBinaryMsg(oscAddress, dataArray),  'b')


def sendBundle(bundle, ipAddr='127.0.0.1', port=9000) :
convert bundle to a binary and send it

outSocket.sendto(bundle.message, (ipAddr, port))
	


def createBinaryMsg(oscAddress, dataArray):
create and return general type binary OSC msg

m = OSC.OSCMessage()
m.address = oscAddress

for x in dataArray:  ## append each item of the array to the message
m.append(x)

return m.getBinary() # get the actual OSC to send



 receive osc from The Other.

class OSCServer(Thread) :
def __init__(self, ipAddr='127.0.0.1', port = 9001) :
Thread.__init__(self)
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try :
self.socket.bind( (ipAddr, port) )
self.socket.settimeout(1.0) # make sure its not blocking forever...
self.haveSocket=True
except socket.error:
print('there was an error binding to ip %s and port %i , maybe the port is already taken by another process?' % (ipAddr. port))
self.haveSocket=False

def run(self):
if self.haveSocket :
self.isRunning = True
while self.isRunning:
try:
while 1:
addressManager.handle( self.socket.recv(1024) ) # self.socket.recvfrom(2**13)
except:
return no data arrived # not data arrived


def listen(ipAddr='127.0.0.1', port = 9001) :
  creates a new thread listening to that port 
defaults to ipAddr='127.0.0.1', port 9001

global oscThread
oscThread = OSCServer(ipAddr, port)
oscThread.start()


def dontListen() :
 closes the socket and kills the thread

global oscThread
if oscThread :
oscThread.socket.close()
oscThread.isRunning = 0 # kill it and free the socket
oscThread = 0




Re: [PD] [unpackOSC] wrong packet crash

2010-05-13 Thread Martin Peach

patko wrote:

hello,

 from experiencing osc packets with another program (I was manipulating 
simpleOSC for python 3),
 I've sent a bad bytes packet and then unpackOSC just crashed,
 I thought you might be interested to know,
 maybe an error message could save the pd session when it happens?



So it's [unpackOSC] that crashes, not [slipdec]...
[unpackOSC] shouldn't crash Pd either. I was unaware of that. Thanks for 
telling me, although a patch that reliably causes the crash would be 
nice to see.
I find it amusing hat Pd is able to peg all of these advanced operating 
systems that are supposedly able to control themselves. It must be one 
of the biggest security threats around.


Martin



Patrice Colet - 06 32 66 03 57 


- martin peach martin.pe...@sympatico.ca a écrit :


It should not crash Pd though, that's bad...







___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] [unpackOSC] wrong packet crash

2010-05-13 Thread Martin Peach

patko wrote:

- Martin Peach martin.pe...@sympatico.ca a écrit :

telling me, although a patch that reliably causes the crash would be 
nice to see.


I've attached an archive containing the files for testing the crash
it needs a python 3 interpreter or blender 2.5(, that should be easy to get on 
the website,
strike p key, when cursor is over the scene,
 for running the script inside the blend file sending osc packet)

I didn't have patience to find out how to trig the crash on python 2.

there is the simple-osc module I'm working on, this should send /foo bar
to [udpreceive], when launching the python script.
And the patch to apply to OSC.py for corrupting the packet.
or just rename files.


I get:
Traceback (most recent call last):
  File E:\martin\pd_patches\oscCRASH\oscCRASH\sendOSC.py, line 1, in 
module

import osc
  File E:\martin\pd_patches\oscCRASH\oscCRASH\osc\__init__.py, line 
8, in module

from OSC import *
ImportError: No module named OSC

Which OSC?
Martin

___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


[PD] [unpackOSC] wrong packet crash

2010-05-12 Thread patko
hello,

 from experiencing osc packets with another program (I was manipulating 
simpleOSC for python 3),
 I've sent a bad bytes packet and then unpackOSC just crashed,
 I thought you might be interested to know,
 maybe an error message could save the pd session when it happens?

Patrice Colet - 06 32 66 03 57 

- martin peach martin.pe...@sympatico.ca a écrit :

 It should not crash Pd though, that's bad...


___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list