Message593

Author nobody
Recipients
Date 2002-02-26.05:35:34
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When using struct.pack with Jython 2.1, an attempt to
pack a string longer than 20 characters will cause a
Java array overflow.  See below for example.

% jython
Jython 2.1 on java1.2 (JIT: sunwjit)
Type "copyright", "credits" or "license" for more
information.
>>> a = 'abcd'
>>> b = 8*a
>>> len(b)
32
>>> b
'abcdabcdabcdabcdabcdabcdabcdabcd'
>>> import struct
>>> struct.pack('>32s', b)
Traceback (innermost last):
  File "<console>", line 1, in ?
java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at org.python.modules.struct$ByteStream.write(Compiled
Code)
	at
org.python.modules.struct$ByteStream.writeString(Compiled
Code)
	at
org.python.modules.struct$StringFormatDef.doPack(Compiled
Code)
	at org.python.modules.struct.pack(Compiled Code)
	at java.lang.reflect.Method.invoke(Native Method)
	at
org.python.core.PyReflectedFunction.__call__(Compiled
Code)
	at
org.python.core.PyReflectedFunction.__call__(Compiled
Code)
	at org.python.core.PyObject.__call__(Compiled Code)
	at org.python.core.PyObject.invoke(Compiled Code)
	at org.python.pycode._pyx9.f$0(Compiled Code)
	at org.python.pycode._pyx9.call_function(Compiled
Code)
	at org.python.core.PyTableCode.call(Compiled Code)
	at org.python.core.PyCode.call(Compiled Code)
	at org.python.core.Py.runCode(Compiled Code)
	at org.python.core.Py.exec(Compiled Code)
	at org.python.util.PythonInterpreter.exec(Compiled
Code)
	at
org.python.util.InteractiveInterpreter.runcode(Compiled
Code)
	at
org.python.util.InteractiveInterpreter.runsource(Compiled
Code)
	at
org.python.util.InteractiveInterpreter.runsource(Compiled
Code)
	at org.python.util.InteractiveConsole.push(Compiled
Code)
	at
org.python.util.InteractiveConsole.interact(Compiled
Code)
	at org.python.util.jython.main(Compiled Code)

java.lang.ArrayIndexOutOfBoundsException:
java.lang.ArrayIndexOutOfBoundsException
>>> 
History
Date User Action Args
2008-02-20 17:17:02adminlinkissue522828 messages
2008-02-20 17:17:02admincreate