From dcf0cbef97d1bd8e4c1530ed0754835e0c0d77a1 Mon Sep 17 00:00:00 2001 From: Roman Schnider Date: Mon, 18 Mar 2019 17:24:07 +0100 Subject: [PATCH] Enhanced data length checks for GS1 data Brought up to date with revision 19 of the GS1 General Specifications --- backend/gs1.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/gs1.c b/backend/gs1.c index 1300bea8..74e3ed41 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -198,7 +198,7 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s strcpy(ai_string, ""); // Check for valid AI values and data lengths according to GS1 General - // Specification Release 18, January 2018 + // Specification Release 19, January 2019 for (i = 0; i < ai_count; i++) { error_latch = 2; @@ -435,6 +435,15 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s } break; + // Length 50 Max + case 8009: // OPTSEN + if (data_length[i] > 50) { + error_latch = 1; + } else { + error_latch = 0; + } + break; + // Length 70 Max case 8110: // Coupon code case 8112: // Paperless coupon code @@ -569,6 +578,14 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s } } + if ((ai_value[i] >= 7230) && (ai_value[i] <= 7239)) { // CERT # + if ((data_length[i] < 3) || (data_length[i] > 30)) { + error_latch = 1; + } else { + error_latch = 0; + } + } + if (ai_value[i] == 8003) { // GRAI if ((data_length[i] < 15) || (data_length[i] > 30)) { error_latch = 1;