Commit c9e2c2531efcdec67afd56d9353375f8c0e0f6a5 Parent: 0a8ce63b2db70c55d566d753fc3cb26fab7e5c95 Author: mcol <mcol@posteo.net> Date: 2020-10-25 20:17:03 +0000 Committer: mcol <mcol@posteo.net> Committed: 2020-10-25 20:17:03 +0000 error and exit if data could not be read correctly
bdf2flf.c Modified
@@ -16,10 +16,14 @@ char *s; int widest = 0; int comments = 2; - int chars, height, baseline, old_layout, direction, full_layout, codetags, - fbb_width, fbb_height, fbb_yoffset; + int baseline, old_layout, direction, full_layout, codetags; char font[1024]; char copyright[1024]; + int chars = 0; + int height = 0; + int fbb_width = 0; + int fbb_height = 0; + int fbb_yoffset = 0; for (;;) { if (!fgets(linebuf, sizeof(linebuf), in)) { // EOF @@ -47,6 +51,12 @@ } } + // exit if data could not be read completely + if (chars <= 0 || fbb_width <= 0 || fbb_height <= 0 || height <= 0) { + fprintf(stderr, "Could not extract BDF data. Is the input a BDF file?\n"); + exit(EXIT_FAILURE); + } + // output header fprintf(out, "flf2a$ %i %i %i %i %i %i %i %i\n", height, baseline, widest+2, old_layout, comments, direction, full_layout, codetags); @@ -54,6 +64,7 @@ if (comments > 2) fprintf(out, "which has copyright: %s\n", copyright); fprintf(out, "Converted to flf with bdf2flf (c) Matt Colligan.\n"); + }