- raster.c: Need ceilf(symbol->height * si) to avoid heap-buffer-overflow;

also avoid distributive multiplication with floats to lessen chances of
  platform variation (#204 ARM-Cortex crash)
- raster.c: Don't allow for text if scale < 1.0
- raster.c: Cast some indexes to (size_t) to allow for large scale
- vector.c: Check malloc()s and return ZINT_ERROR_MEMORY on fail
- raster/vector.c: various var name changes & other code fiddling
- library.c: Check that scale/height/whitespace/border are reasonable values:
  scale (0.01-100), height (0-500), whitespace_width/height (0-100),
  border_width (0-100)
- CLI: allow both e.g. '-height' and '--height' (getopt_long_only())
- gif.c: fix GIF_ZLW_PAGE_SIZE -> GIF_LZW_PAGE_SIZE
- GUI: allow whitespace/scale to 100
This commit is contained in:
gitlost 2021-09-20 14:56:27 +01:00
parent 5766b39845
commit 9bae0b86f9
19 changed files with 870 additions and 814 deletions

View file

@ -521,7 +521,7 @@ static int batch_process(struct zint_symbol *symbol, const char *filename, const
} else {
file = fopen(filename, "rb");
if (!file) {
strcpy(symbol->errtxt, "102: Unable to read input file");
sprintf(symbol->errtxt, "102: Unable to read input file '%s'", filename);
return ZINT_ERROR_INVALID_DATA;
}
}
@ -776,6 +776,7 @@ int main(int argc, char **argv) {
#else
arg_opt *arg_opts = (arg_opt *) _alloca(argc * sizeof(arg_opt));
#endif
int no_getopt_error = 1;
if (argc == 1) {
usage();
@ -794,7 +795,7 @@ int main(int argc, char **argv) {
win_args(&argc, &argv);
#endif
while (1) {
while (no_getopt_error) {
enum options {
OPT_ADDONGAP = 128, OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BOLD, OPT_BORDER,
OPT_BOX, OPT_CMYK, OPT_COLS, OPT_DIRECT, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
@ -863,7 +864,7 @@ int main(int argc, char **argv) {
{"whitesp", 1, NULL, 'w'},
{NULL, 0, NULL, 0}
};
int c = getopt_long(argc, argv, "b:d:ehi:o:rtw:", long_options, &option_index);
int c = getopt_long_only(argc, argv, "b:d:ehi:o:rtw:", long_options, &option_index);
if (c == -1) break;
switch (c) {
@ -1258,11 +1259,13 @@ int main(int argc, char **argv) {
break;
case '?':
no_getopt_error = 0;
break;
default:
fprintf(stderr, "Error 123: ?? getopt error 0%o\n", c);
default: /* Shouldn't happen */
fprintf(stderr, "Error 123: ?? getopt error 0%o\n", c); /* Not reached */
fflush(stderr);
no_getopt_error = 0;
break;
}
}