From aac963bb2d95db0ec7aa27f0e12159ee8edbb168 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 23 Jul 2022 12:18:01 -0700 Subject: show_font_props: skip copy to temporary buffer Avoids risk of overflow since we weren't bounds checking and may slightly improve performance. Signed-off-by: Alan Coopersmith --- fslsfonts.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fslsfonts.c b/fslsfonts.c index 5afc07b..3138a81 100644 --- a/fslsfonts.c +++ b/fslsfonts.c @@ -494,7 +494,6 @@ static void show_font_props(FontList *list) { unsigned int i; - char buf[1000]; FSPropInfo *pi = list->pi; FSPropOffset *po = list->po; unsigned char *pd = list->pd; @@ -502,14 +501,12 @@ show_font_props(FontList *list) num_props = pi->num_offsets; for (i = 0; i < num_props; i++, po++) { - strncpy(buf, (char *) (pd + po->name.position), po->name.length); - buf[po->name.length] = '\0'; - printf("%s\t", buf); + fwrite(pd + po->name.position, 1, po->name.length, stdout); + putc('\t', stdout); switch (po->type) { case PropTypeString: - strncpy(buf, (char *)pd + po->value.position, po->value.length); - buf[po->value.length] = '\0'; - printf("%s\n", buf); + fwrite(pd + po->value.position, 1, po->value.length, stdout); + putc('\n', stdout); break; case PropTypeUnsigned: printf("%lu\n", (unsigned long) po->value.position); -- cgit v1.2.3