mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Try to protect from malformed colours
This commit is contained in:
parent
32b6bbaf0e
commit
b531abf9b4
@ -40,6 +40,7 @@
|
||||
#include "gs1.h"
|
||||
|
||||
#define TECHNETIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
|
||||
#define TITANIUM "01234567890ABCDEFabcdef"
|
||||
|
||||
struct zint_symbol *ZBarcode_Create() {
|
||||
struct zint_symbol *symbol;
|
||||
@ -1129,6 +1130,20 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
//Check value of colours
|
||||
if ((strlen(symbol->bgcolour) > 6) || (strlen(symbol->fgcolour) > 6)) {
|
||||
strcpy(symbol->errtxt, "232: Invalid colour");
|
||||
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
if ((is_sane(TITANIUM, (unsigned char *)symbol->bgcolour, strlen(symbol->bgcolour)) == ZINT_ERROR_INVALID_DATA)
|
||||
|| (is_sane(TITANIUM, (unsigned char *)symbol->fgcolour, strlen(symbol->bgcolour)) == ZINT_ERROR_INVALID_DATA)) {
|
||||
strcpy(symbol->errtxt, "233: Invalid characters in colour");
|
||||
error_tag(symbol->errtxt, ZINT_ERROR_INVALID_OPTION);
|
||||
return ZINT_ERROR_INVALID_OPTION;
|
||||
}
|
||||
|
||||
switch (symbol->symbology) {
|
||||
case BARCODE_QRCODE:
|
||||
case BARCODE_MICROQR:
|
||||
|
Loading…
Reference in New Issue
Block a user