zint / zint-gpl-only

Zint Barcode Generator
https://zint.org.uk/
GNU General Public License v3.0
525 stars 138 forks source link

Plessey Check : unsigned iterator never negative #48

Closed arnejpackz closed 8 years ago

arnejpackz commented 8 years ago

You can find this code twice in plessey.c:

for(i = src_len - 1; i >= 0; i--) { x += weight * ctoi(source[i]);

The problem is that i was declared unsigned, so this is an infinite loop (until the point of memory corruption). The easiest fix is to modify to

for(i = src_len; i; i--) { x += weight * ctoi(source[ i - 1 ]);

oehhar commented 8 years ago

Sorry on business trip. But if I remember right this was corrected. Could you verify if this is still in the current trunk on sourceforge.net ?

Thank you, Harald

Am 03.09.2015 um 09:45 schrieb arnejpackz:

You can find this code twicein plessey.c:

for(i = src_len - 1; i >= 0; i--) { x += weight * ctoi(source[i]);

The problem is that i was declared unsigned, so this is an infinite loop (until the point of memory corruption). The easiest fix is to modify to

for(i = src_len; i; i--) { x += weight * ctoi(source[ i - 1 ]);

arnejpackz commented 8 years ago

It appears you are correct. I forgot to compare to the current master brach. The latest code is no longer using unsigned integers.