mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Buffer over-flow --
warnings --
This commit is contained in:
parent
afd0ca7cfd
commit
414bc1c82b
@ -97,14 +97,14 @@ void upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
source[length] = upc_check(source);
|
source[length] = upc_check(source);
|
||||||
source[length + 1] = '\0';
|
source[length + 1] = '\0';
|
||||||
upca_draw(source, dest);
|
upca_draw(source, dest);
|
||||||
strcpy(symbol->text, source);
|
strcpy(symbol->text, (char*)source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
||||||
{ /* UPC E is a zero-compressed version of UPC A */
|
{ /* UPC E is a zero-compressed version of UPC A */
|
||||||
unsigned int i, num_system;
|
unsigned int i, num_system;
|
||||||
char emode, equivalent[12], check_digit, parity[8], temp[8];
|
char emode, equivalent[12], check_digit, parity[8], temp[8];
|
||||||
char hrt[8];
|
char hrt[9];
|
||||||
|
|
||||||
/* Two number systems can be used - system 0 and system 1 */
|
/* Two number systems can be used - system 0 and system 1 */
|
||||||
if(ustrlen(source) == 7) {
|
if(ustrlen(source) == 7) {
|
||||||
@ -113,8 +113,8 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
case '1': num_system = 1; break;
|
case '1': num_system = 1; break;
|
||||||
default: num_system = 0; source[0] = '0'; break;
|
default: num_system = 0; source[0] = '0'; break;
|
||||||
}
|
}
|
||||||
strcpy(temp, source);
|
strcpy(temp, (char*)source);
|
||||||
strcpy(hrt, source);
|
strcpy(hrt, (char*)source);
|
||||||
for(i = 1; i <= 7; i++) {
|
for(i = 1; i <= 7; i++) {
|
||||||
source[i - 1] = temp[i];
|
source[i - 1] = temp[i];
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
num_system = 0;
|
num_system = 0;
|
||||||
hrt[0] = '0';
|
hrt[0] = '0';
|
||||||
hrt[1] = '\0';
|
hrt[1] = '\0';
|
||||||
concat(hrt, source);
|
concat(hrt, (char*)source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand the zero-compressed UPCE code to make a UPCA equivalent (EN Table 5) */
|
/* Expand the zero-compressed UPCE code to make a UPCA equivalent (EN Table 5) */
|
||||||
@ -181,7 +181,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
|
|
||||||
/* Get the check digit from the expanded UPCA code */
|
/* Get the check digit from the expanded UPCA code */
|
||||||
|
|
||||||
check_digit = upc_check(equivalent);
|
check_digit = upc_check((unsigned char*)equivalent);
|
||||||
|
|
||||||
/* Use the number system and check digit information to choose a parity scheme */
|
/* Use the number system and check digit information to choose a parity scheme */
|
||||||
if(num_system == 1) {
|
if(num_system == 1) {
|
||||||
@ -344,7 +344,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
/* stop character */
|
/* stop character */
|
||||||
concat (dest, "111");
|
concat (dest, "111");
|
||||||
|
|
||||||
strcpy(symbol->text, source);
|
strcpy(symbol->text, (char*)source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
||||||
@ -356,7 +356,7 @@ void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
source[length] = upc_check(source);
|
source[length] = upc_check(source);
|
||||||
source[length + 1] = '\0';
|
source[length + 1] = '\0';
|
||||||
upca_draw(source, dest);
|
upca_draw(source, dest);
|
||||||
strcpy(symbol->text, source);
|
strcpy(symbol->text, (char*)source);
|
||||||
}
|
}
|
||||||
|
|
||||||
char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
|
char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
|
||||||
@ -490,14 +490,14 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
int eanx(struct zint_symbol *symbol, unsigned char source[])
|
int eanx(struct zint_symbol *symbol, unsigned char source[])
|
||||||
{
|
{
|
||||||
/* splits string to parts before and after '+' parts */
|
/* splits string to parts before and after '+' parts */
|
||||||
char first_part[20], second_part[20], dest[1000];
|
unsigned char first_part[20], second_part[20], dest[1000];
|
||||||
unsigned int latch, reader, writer, with_addon;
|
unsigned int latch, reader, writer, with_addon;
|
||||||
strcpy(first_part, "");
|
|
||||||
strcpy(second_part, "");
|
|
||||||
int errno, i;
|
int errno, i;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
strcpy(dest, "");
|
memset(dest,0,1000);
|
||||||
|
memset(first_part,0,20);
|
||||||
|
memset(second_part,0,20);
|
||||||
|
|
||||||
with_addon = FALSE;
|
with_addon = FALSE;
|
||||||
latch = FALSE;
|
latch = FALSE;
|
||||||
@ -542,24 +542,24 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
} while (reader <= ustrlen(source));
|
} while (reader <= ustrlen(source));
|
||||||
} else {
|
} else {
|
||||||
strcpy(first_part, source);
|
strcpy((char*)first_part, (char*)source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch(symbol->symbology)
|
switch(symbol->symbology)
|
||||||
{
|
{
|
||||||
case BARCODE_EANX:
|
case BARCODE_EANX:
|
||||||
switch(strlen(first_part))
|
switch(ustrlen(first_part))
|
||||||
{
|
{
|
||||||
case 2: add_on(first_part, dest, 0); strcpy(symbol->text, first_part); break;
|
case 2: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break;
|
||||||
case 5: add_on(first_part, dest, 0); strcpy(symbol->text, first_part); break;
|
case 5: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break;
|
||||||
case 7: ean8(symbol, first_part, dest); break;
|
case 7: ean8(symbol, first_part, (char*)dest); break;
|
||||||
case 12: ean13(symbol, first_part, dest); break;
|
case 12: ean13(symbol, first_part, (char*)dest); break;
|
||||||
default: strcpy(symbol->errtxt, "error: invalid length input"); return ERROR_TOO_LONG; break;
|
default: strcpy(symbol->errtxt, "error: invalid length input"); return ERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_EANX_CC:
|
case BARCODE_EANX_CC:
|
||||||
switch(strlen(first_part))
|
switch(ustrlen(first_part))
|
||||||
{ /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
|
{ /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
|
||||||
case 7: symbol->encoded_data[symbol->rows][1] = '1';
|
case 7: symbol->encoded_data[symbol->rows][1] = '1';
|
||||||
symbol->encoded_data[symbol->rows][67] = '1';
|
symbol->encoded_data[symbol->rows][67] = '1';
|
||||||
@ -571,7 +571,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->row_height[symbol->rows + 1] = 2;
|
symbol->row_height[symbol->rows + 1] = 2;
|
||||||
symbol->row_height[symbol->rows + 2] = 2;
|
symbol->row_height[symbol->rows + 2] = 2;
|
||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
ean8(symbol, first_part, dest); break;
|
ean8(symbol, first_part, (char*)dest); break;
|
||||||
case 12:symbol->encoded_data[symbol->rows][1] = '1';
|
case 12:symbol->encoded_data[symbol->rows][1] = '1';
|
||||||
symbol->encoded_data[symbol->rows][95] = '1';
|
symbol->encoded_data[symbol->rows][95] = '1';
|
||||||
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
||||||
@ -582,20 +582,20 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->row_height[symbol->rows + 1] = 2;
|
symbol->row_height[symbol->rows + 1] = 2;
|
||||||
symbol->row_height[symbol->rows + 2] = 2;
|
symbol->row_height[symbol->rows + 2] = 2;
|
||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
ean13(symbol, first_part, dest); break;
|
ean13(symbol, first_part, (char*)dest); break;
|
||||||
default: strcpy(symbol->errtxt, "error: invalid length EAN input"); return ERROR_TOO_LONG; break;
|
default: strcpy(symbol->errtxt, "error: invalid length EAN input"); return ERROR_TOO_LONG; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCA:
|
case BARCODE_UPCA:
|
||||||
if(strlen(first_part) == 11) {
|
if(ustrlen(first_part) == 11) {
|
||||||
upca(symbol, first_part, dest);
|
upca(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "error: input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCA_CC:
|
case BARCODE_UPCA_CC:
|
||||||
if(strlen(first_part) == 11) {
|
if(ustrlen(first_part) == 11) {
|
||||||
symbol->encoded_data[symbol->rows][1] = '1';
|
symbol->encoded_data[symbol->rows][1] = '1';
|
||||||
symbol->encoded_data[symbol->rows][95] = '1';
|
symbol->encoded_data[symbol->rows][95] = '1';
|
||||||
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
||||||
@ -606,22 +606,22 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->row_height[symbol->rows + 1] = 2;
|
symbol->row_height[symbol->rows + 1] = 2;
|
||||||
symbol->row_height[symbol->rows + 2] = 2;
|
symbol->row_height[symbol->rows + 2] = 2;
|
||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
upca(symbol, first_part, dest);
|
upca(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: UPCA input wrong length");
|
strcpy(symbol->errtxt, "error: UPCA input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE:
|
case BARCODE_UPCE:
|
||||||
if((strlen(first_part) >= 6) && (strlen(first_part) <= 7)) {
|
if((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
|
||||||
upce(symbol, first_part, dest);
|
upce(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: input wrong length");
|
strcpy(symbol->errtxt, "error: input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_UPCE_CC:
|
case BARCODE_UPCE_CC:
|
||||||
if((strlen(first_part) >= 6) && (strlen(first_part) <= 7)) {
|
if((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
|
||||||
symbol->encoded_data[symbol->rows][1] = '1';
|
symbol->encoded_data[symbol->rows][1] = '1';
|
||||||
symbol->encoded_data[symbol->rows][51] = '1';
|
symbol->encoded_data[symbol->rows][51] = '1';
|
||||||
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
symbol->encoded_data[symbol->rows + 1][0] = '1';
|
||||||
@ -632,31 +632,31 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->row_height[symbol->rows + 1] = 2;
|
symbol->row_height[symbol->rows + 1] = 2;
|
||||||
symbol->row_height[symbol->rows + 2] = 2;
|
symbol->row_height[symbol->rows + 2] = 2;
|
||||||
symbol->rows += 3;
|
symbol->rows += 3;
|
||||||
upce(symbol, first_part, dest);
|
upce(symbol, first_part, (char*)dest);
|
||||||
} else {
|
} else {
|
||||||
strcpy(symbol->errtxt, "error: UPCE input wrong length");
|
strcpy(symbol->errtxt, "error: UPCE input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_ISBNX:
|
case BARCODE_ISBNX:
|
||||||
errno = isbn(symbol, first_part, dest);
|
errno = isbn(symbol, first_part, (char*)dest);
|
||||||
if(errno > 4) {
|
if(errno > 4) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch(strlen(second_part))
|
switch(ustrlen(second_part))
|
||||||
{
|
{
|
||||||
case 0: break;
|
case 0: break;
|
||||||
case 2:
|
case 2:
|
||||||
add_on(second_part, dest, 1);
|
add_on(second_part, (char*)dest, 1);
|
||||||
concat(symbol->text, "+");
|
concat(symbol->text, "+");
|
||||||
concat(symbol->text, second_part);
|
concat(symbol->text, (char*)second_part);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
add_on(second_part, dest, 1);
|
add_on(second_part, (char*)dest, 1);
|
||||||
concat(symbol->text, "+");
|
concat(symbol->text, "+");
|
||||||
concat(symbol->text, second_part);
|
concat(symbol->text, (char*)second_part);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(symbol->errtxt, "error: invalid length input");
|
strcpy(symbol->errtxt, "error: invalid length input");
|
||||||
@ -664,7 +664,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
expand(symbol, dest);
|
expand(symbol, (char*)dest);
|
||||||
|
|
||||||
switch(symbol->symbology) {
|
switch(symbol->symbology) {
|
||||||
case BARCODE_EANX_CC:
|
case BARCODE_EANX_CC:
|
||||||
|
Loading…
Reference in New Issue
Block a user