Cups4J.org
http://www.cups4j.org/forum/

Bug in IppTag
http://www.cups4j.org/forum/viewtopic.php?f=6&t=56
Page 1 of 1

Author:  rnentjes [ Fri May 24, 2013 11:39 am ]
Post subject:  Bug in IppTag

Hello,

We noticed some problems with the Ippclient when using multi-byte characters. There is a bug in IppTag.java class where the length of the string is written incorrectly into the IppBuffer for multi-byte characters.

This is the code in IppTag (this is used in multiple places in IppTag class):

ippBuf.putShort((short)attributeName.length());
ippBuf.put(IppConverter.toBytes(attributeName));

The problem is that the length of the string is not the same as the length in bytes after encoding as some encodings have multy-byte characters (for example utf-8). We noticed this when sending a printjob with a job-name containing characters like è, é, ê, ë.

My fix would be as follows:

byte [] bytes = IppConverter.toBytes(attributeName);
ippBuf.putShort((short)bytes.length);
ippBuf.put(bytes);

I also informed the maker of ippclient (https://trac.id.ethz.ch/projects/ippclient) of this problem and they will release a fix shortly.

Cheers,

Rien Nentjes

Author:  Harald [ Sun Jun 02, 2013 5:02 pm ]
Post subject:  Re: Bug in IppTag

This will be fixed in the next version.

Thanks for your path.

Cheers Harald

Author:  Harald [ Fri Jul 12, 2013 7:58 pm ]
Post subject:  Re: Bug in IppTag

I just uploaded a new version of cups4j with this bug fixed and some logging features.

Harald

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/