From ecb10e6b7db4d46b2d03e14b7f3f1eb262bb58c0 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sun, 22 Jan 2017 19:12:11 +0000 Subject: [PATCH] Don't initialise roots beyond end of field AKA don't use code from draft standards without testing it! Bug reported by Christian Sakowski --- backend/dotcode.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/backend/dotcode.c b/backend/dotcode.c index 2d294d86..6d19480a 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -184,7 +184,7 @@ void rsencode(int nd, int nc, unsigned char *wd) { // Start by generating "nc" roots (antilogs): root[0] = 1; - for (i = 1; i <= nc; i++) + for (i = 1; (i <= nc) && (i < GF); i++) root[i] = (PM * root[i - 1]) % GF; // Here we compute how many interleaved R-S blocks will be needed @@ -1121,13 +1121,6 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length data_length++; } - if (data_length > 450) { - // Larger data sets than this cause rsencode() to throw SIGSEGV - // This should probably be fixed by somebody who understands what rsencode() does... - strcpy(symbol->errtxt, "Input too long (E21)"); - return ZINT_ERROR_TOO_LONG; - } - ecc_length = 3 + (data_length / 2); /* Evaluate data mask options */