shithub: neatpost

Download patch

ref: 689cb60650e64a064899bcbd8ab47a6d4485ef32
parent: a79e7c463a998eb249b2c6d0d010e7540a329ce2
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Aug 17 12:44:50 EDT 2022

font: fix maximum field width in scanf %s specifier

--- a/dev.c
+++ b/dev.c
@@ -62,7 +62,7 @@
 	desc = fopen(path, "r");
 	if (!desc)
 		return 1;
-	while (fscanf(desc, "%128s", tok) == 1) {
+	while (fscanf(desc, "%127s", tok) == 1) {
 		if (tok[0] == '#') {
 			skipline(desc);
 			continue;
@@ -75,7 +75,7 @@
 			continue;
 		}
 		if (!strcmp("sizes", tok)) {
-			while (fscanf(desc, "%128s", tok) == 1)
+			while (fscanf(desc, "%127s", tok) == 1)
 				if (!strcmp("0", tok))
 					break;
 			continue;
--- a/font.c
+++ b/font.c
@@ -68,7 +68,7 @@
 	char name[GNLEN];
 	char id[GNLEN];
 	int type;
-	if (fscanf(fin, GNFMT " %128s", name, tok) != 2)
+	if (fscanf(fin, GNFMT " %127s", name, tok) != 2)
 		return 1;
 	if (!strcmp("---", name))
 		sprintf(name, "c%04d", *n);
@@ -117,7 +117,7 @@
 	fn->gl_dict = dict_make(-1, 1, 0);
 	fn->ch_dict = dict_make(-1, 1, 0);
 	fn->ch_map = dict_make(-1, 1, 0);
-	while (fscanf(fin, "%128s", tok) == 1) {
+	while (fscanf(fin, "%127s", tok) == 1) {
 		if (!strcmp("char", tok)) {
 			font_readchar(fn, fin, &ch_n, &ch_g);
 		} else if (!strcmp("spacewidth", tok)) {
--- a/post.h
+++ b/post.h
@@ -3,7 +3,7 @@
 #define NFONTS		1024	/* number of fonts */
 #define FNLEN		64	/* font name length */
 #define GNLEN		32	/* glyph name length */
-#define GNFMT		"%32s"	/* glyph name scanf format */
+#define GNFMT		"%31s"	/* glyph name scanf format */
 #define ILNLEN		1000	/* line limit of input files */
 
 #define MIN(a, b)	((a) < (b) ? (a) : (b))