summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-trace.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-09-03 12:54:23 +0900
committerMichael Paquier <michael@paquier.xyz>2025-09-03 12:54:23 +0900
commitdb9405493b489c6a348c97f532753290eea8adbd (patch)
tree55795e6a94f26d24d554897890195564aae7e4ef /src/interfaces/libpq/fe-trace.c
parentc6ea528b470f45832437f2a937cf2f4483d23737 (diff)
libpq: Fix PQtrace() format for non-printable characters
PQtrace() was generating its output for non-printable characters without casting the characters printed with unsigned char, leading to some extra "\xffffff" generated in the output due to the fact that char may be signed. Oversights introduced by commit 198b3716dba6, so backpatch down to v14. Author: Ran Benita <ran@unusedvar.com> Discussion: https://postgr.es/m/a3383211-4539-459b-9d51-95c736ef08e0@app.fastmail.com Backpatch-through: 14
Diffstat (limited to 'src/interfaces/libpq/fe-trace.c')
-rw-r--r--src/interfaces/libpq/fe-trace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-trace.c b/src/interfaces/libpq/fe-trace.c
index a45f0d85587..fae5b47e551 100644
--- a/src/interfaces/libpq/fe-trace.c
+++ b/src/interfaces/libpq/fe-trace.c
@@ -113,7 +113,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor)
* that completes ErrorResponse and NoticeResponse messages.
*/
if (!isprint((unsigned char) *v))
- fprintf(pfdebug, " \\x%02x", *v);
+ fprintf(pfdebug, " \\x%02x", (unsigned char) *v);
else
fprintf(pfdebug, " %c", *v);
*cursor += 1;
@@ -212,7 +212,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor, bool s
else
{
fwrite(v + next, 1, i - next, pfdebug);
- fprintf(pfdebug, "\\x%02x", v[i]);
+ fprintf(pfdebug, "\\x%02x", (unsigned char) v[i]);
next = i + 1;
}
}