summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-07-23 12:18:01 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-07-23 12:18:01 -0700
commitaac963bb2d95db0ec7aa27f0e12159ee8edbb168 (patch)
tree4e34e351df7068b5ef49f23e8934b54a1090641f
parent44c1649d2a11c89137488c53e3a1c383fe79c2c1 (diff)
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 <alan.coopersmith@oracle.com>
-rw-r--r--fslsfonts.c11
1 files 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);