hoijui / JavaOSC

OSC content format/"protocol" library for JVM languages
http://www.illposed.com/software/javaosc.html
BSD 3-Clause "New" or "Revised" License
156 stars 43 forks source link

Crash on 4 byte OSCMessages #3

Closed Burtan closed 10 years ago

Burtan commented 11 years ago

Hi,

please add some statements to check for 4 byte OSCMessages before checking if it is a bundle and before typechecking of that OSCMessage. I can propose it myself, but I'm not that used to gitHub, so it will certainly be faster, when someone of you will do it ;-)

Thanks!

hoijui commented 10 years ago

thanks for the report! You are right... in the specs (http://opensoundcontrol.org/spec-1_0) they state:

The contents of an OSC packet must be either an OSC Message or an OSC Bundle. The first byte of the packet's contents unambiguously distinguishes between these two alternatives.

OSC Messages

An OSC message consists of an OSC Address Pattern followed by an OSC Type Tag String followed by zero or more OSC Arguments.

Note: some older implementations of OSC may omit the OSC Type Tag string. Until all such implementations are updated, OSC implementations should be robust in the case of a missing OSC Type Tag String.

This means, that the shortest packet can be of size 4 bytes (with old implementations), as you say. This crashes our current code, which checks the first 7 bytes for if they match "#bundle". As this part of the spec also states, we just have to check the first byte for if it equals '#', as this character is not allowed in OSC addresses, and therefore is unambiguous.

Fix is underway!

hoijui commented 10 years ago

fixed in: https://github.com/hoijui/JavaOSC/commit/069a9161ce91efd3b2342578a3c12aeac6bebcd2