[liblouis-liblouisxml] Re: Python bindings and output buffer size for lou_translate*

  • From: Christian Egli <christian.egli@xxxxxxxx>
  • To: James Teh <jamie@xxxxxxxxxxxx>
  • Date: Mon, 02 Aug 2010 14:21:47 +0200

Hi

James Teh <jamie@xxxxxxxxxxxx> writes:

> Hi all,
>
> For lou_translate* in the Python bindings, we've made an assumption
> that outlen should be 2 * inlen. However, this assumption is very
> wrong if there are characters in the input which aren't defined in the
> specified tables. 

I've also run into this issue when using the correct opcode, e.g.
correct "foo" "foobarbaz".

> I'd like to change the Python bindings to do this and suggest that
> perhaps the documentation should be updated with a similar guideline.

Has there been any conclusion on this, i.e. as to how to change the
bindings? In my case the problem was that the bindings had a buffer
overrun and crashed the Python interpreter outright. OK, I discovered
that the correct opcode in case was faulty and changed that, but it
should never take down the entire Python interpreter.

> An alternative is to keep checking whether translation wasn't
> completed (i.e. inlen is less than its original value) and then
> increase outlen if so, probably multiplying outlen by 2 each time.

How do you do this, I mean how do you check for buffer overrun from the
Python bindings.

> What do people think?

I would welcome a solution to this. Increasing the ratio would be fine
by me.

Thanks
Christian

-- 
Christian Egli
Swiss Library for the Blind, Visually Impaired and Print Disabled
Grubenstrasse 12, CH-8045 Zürich, Switzerland
For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts: