Closed Mutantpenguin closed 3 years ago
Well I might have found something in this and the following 6 lines here: https://github.com/zorantica/plsql-qr-code/blob/fbf3d6fbb8e1cedfbac7ae47b20b945982c40fc1/package/ZT_QR.pkb#L958
It currently looks like this:
if lnReqNumOfBits - lengthb(p_data) >= 4 then
lcData := lcData || '0000';
p_debug('Terminator zeros: 0000', 2);
else
lcData := rpad(lcData, lnReqNumOfBits - lengthb(p_data), '0');
p_debug('Terminator zeros: ' || rpad(null, lnReqNumOfBits - lengthb(p_data), '0'), 2);
end if;
In here, p_data
gets referenced quite a lot, but lcData
gets changed. This leads to the initial problem that the length of lcData
is highter than lnReqNumOfBits
. The LOOP mentioned in my issue description will thus enter an infinit (until the buffer overflows) loop since the check there is only on equality.
Apart from that I am pretty sure that the rpad is wrong too. Like this lcData
will get overwritten with a very short string most of the time.
I changed it to this in my local version and it seems to work correctly:
if lnReqNumOfBits - lengthb(lcData) >= 4 then
lcData := lcData || '0000';
p_debug('Terminator zeros: 0000', 2);
else
lcData := rpad(lcData, lnReqNumOfBits, '0');
p_debug('Terminator zeros: ' || rpad(null, lnReqNumOfBits, '0'), 2);
end if;
Of course I don't know if this is the real solution. If this is correct I will create a pull request for you.
Thank You for discovering this BUG!
And You are right - parameter p_data was used instead of local variable lcData. Also, rpad string length value was problematic. I added some additional debugging and I will prepare new version immediately.
Fixed! New version is available.
You are welcome! And thank you for providing this package.
The package crashes on strings which have a special length. My environment is an Oracle Server 12.2.0.1.0 with characterset set to AL32UTF8. I first thought there might be some problem with my input, but just using a string only containing the character "A" multiple times triggers the same error:
in the function
f_encode_data
in this block of code:Example:
Changing just one uppercase "A" against a lowercase one make the error go away.
I wrote a small script to find problematic strings:
Here are some examples for strings only containing the character "A" which produce the problem:
I am willing to help solve this problem but at this point I don't understand your code enough to do so.