From 9e20406dd847d0f8c1cbd803786c6d0ad33bcbdd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 31 Mar 2021 17:14:16 -0400 Subject: [PATCH] Fix unportable use of isprint(). We must cast the arguments of functions to unsigned char to avoid problems where char is signed. Speaking of which, considering that this *is* a function, it's rather remarkable that we aren't seeing more complaints about not having included that header. Per buildfarm. --- src/interfaces/libpq/fe-trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interfaces/libpq/fe-trace.c b/src/interfaces/libpq/fe-trace.c index 5faeee7451..ca59c18318 100644 --- a/src/interfaces/libpq/fe-trace.c +++ b/src/interfaces/libpq/fe-trace.c @@ -14,6 +14,7 @@ #include "postgres_fe.h" +#include #include #include @@ -28,6 +29,7 @@ #include "libpq-int.h" #include "port/pg_bswap.h" + /* Enable tracing */ void PQtrace(PGconn *conn, FILE *debug_port) @@ -102,7 +104,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor) * Show non-printable data in hex format, including the terminating \0 * that completes ErrorResponse and NoticeResponse messages. */ - if (!isprint(*v)) + if (!isprint((unsigned char) *v)) fprintf(pfdebug, " \\x%02x", *v); else fprintf(pfdebug, " %c", *v); @@ -186,7 +188,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor) for (next = i = 0; i < len; ++i) { - if (isprint(v[i])) + if (isprint((unsigned char) v[i])) continue; else { -- 2.39.5