summaryrefslogtreecommitdiff
path: root/lib/libXfont2/src/fc/fserve.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libXfont2/src/fc/fserve.c')
-rw-r--r--lib/libXfont2/src/fc/fserve.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/lib/libXfont2/src/fc/fserve.c b/lib/libXfont2/src/fc/fserve.c
index 708fc35ef..2d9c2c231 100644
--- a/lib/libXfont2/src/fc/fserve.c
+++ b/lib/libXfont2/src/fc/fserve.c
@@ -54,6 +54,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#ifdef WIN32
#define _WILLWINSOCK_
@@ -223,8 +224,8 @@ _fs_add_rep_log (FSFpePtr conn, fsGenericReply *rep)
fprintf (stderr, "Error: %d Request: %s\n", \
((fsError *)rep)->request, #name); \
else \
- fprintf (stderr, "Bad Length for %s Reply: %d %s %d\n", \
- #name, rep->length, op, LENGTHOF(name)); \
+ fprintf (stderr, "Bad Length for %s Reply: %u %s %d\n", \
+ #name, (unsigned) rep->length, op, LENGTHOF(name));\
} \
} while (0)
@@ -933,8 +934,8 @@ fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
ret = -1;
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXInfo: bufleft (%ld) / SIZEOF(fsPropOffset) < %d\n",
- bufleft, pi->num_offsets);
+ "fsQueryXInfo: bufleft (%ld) / SIZEOF(fsPropOffset) < %u\n",
+ bufleft, (unsigned) pi->num_offsets);
#endif
goto bail;
}
@@ -947,8 +948,8 @@ fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
ret = -1;
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXInfo: bufleft (%ld) < data_len (%d)\n",
- bufleft, pi->data_len);
+ "fsQueryXInfo: bufleft (%ld) < data_len (%u)\n",
+ bufleft, (unsigned) pi->data_len);
#endif
goto bail;
}
@@ -1081,14 +1082,14 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
/ LENGTHOF(fsXCharInfo))) {
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXExtents16: numExtents (%d) > (%d - %d) / %d\n",
- numExtents, rep->length,
+ "fsQueryXExtents16: numExtents (%d) > (%u - %d) / %d\n",
+ numExtents, (unsigned) rep->length,
LENGTHOF(fsQueryXExtents16Reply), LENGTHOF(fsXCharInfo));
#endif
pCI = NULL;
}
else
- pCI = malloc(sizeof(CharInfoRec) * numInfos);
+ pCI = mallocarray(numInfos, sizeof(CharInfoRec));
if (!pCI)
{
@@ -1957,8 +1958,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXBitmaps16: num_chars (%d) > bufleft (%ld) / %d\n",
- rep->num_chars, bufleft, SIZEOF (fsOffset32));
+ "fsQueryXBitmaps16: num_chars (%u) > bufleft (%ld) / %d\n",
+ (unsigned) rep->num_chars, bufleft, SIZEOF (fsOffset32));
#endif
err = AllocError;
goto bail;
@@ -1971,8 +1972,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXBitmaps16: nbytes (%d) > bufleft (%ld)\n",
- rep->nbytes, bufleft);
+ "fsQueryXBitmaps16: nbytes (%u) > bufleft (%ld)\n",
+ (unsigned) rep->nbytes, bufleft);
#endif
err = AllocError;
goto bail;
@@ -2078,7 +2079,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
err = Successful;
bail:
- _fs_done_read (conn, rep->length << 2);
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
return err;
}
@@ -2573,8 +2575,8 @@ fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
if (pi->num_offsets > (bufleft / SIZEOF (fsPropOffset))) {
#ifdef DEBUG
fprintf(stderr,
- "fsListFontsWithXInfo: offset length (%d * %d) > bufleft (%ld)\n",
- pi->num_offsets, (int) SIZEOF (fsPropOffset), bufleft);
+ "fsListFontsWithXInfo: offset length (%u * %d) > bufleft (%ld)\n",
+ (unsigned) pi->num_offsets, (int) SIZEOF (fsPropOffset), bufleft);
#endif
err = AllocError;
goto done;
@@ -2585,8 +2587,8 @@ fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
if (pi->data_len > bufleft) {
#ifdef DEBUG
fprintf(stderr,
- "fsListFontsWithXInfo: data length (%d) > bufleft (%ld)\n",
- pi->data_len, bufleft);
+ "fsListFontsWithXInfo: data length (%u) > bufleft (%ld)\n",
+ (unsigned) pi->data_len, bufleft);
#endif
err = AllocError;
goto done;
@@ -3369,8 +3371,9 @@ static FSFpePtr
_fs_init_conn (const char *servername, FontPathElementPtr fpe)
{
FSFpePtr conn;
+ size_t snlen = strlen (servername) + 1;
- conn = calloc (1, sizeof (FSFpeRec) + strlen (servername) + 1);
+ conn = calloc (1, sizeof (FSFpeRec) + snlen);
if (!conn)
return 0;
if (!_fs_io_init (conn))
@@ -3382,7 +3385,7 @@ _fs_init_conn (const char *servername, FontPathElementPtr fpe)
conn->fs_conn_state = FS_CONN_UNCONNECTED;
conn->fs_fd = -1;
conn->fpe = fpe;
- strcpy (conn->servername, servername);
+ strlcpy (conn->servername, servername, snlen);
return conn;
}