mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
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 198b3716db
, 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
This commit is contained in:
@@ -113,7 +113,7 @@ pqTraceOutputByte1(FILE *pfdebug, const char *data, int *cursor)
|
|||||||
* that completes ErrorResponse and NoticeResponse messages.
|
* that completes ErrorResponse and NoticeResponse messages.
|
||||||
*/
|
*/
|
||||||
if (!isprint((unsigned char) *v))
|
if (!isprint((unsigned char) *v))
|
||||||
fprintf(pfdebug, " \\x%02x", *v);
|
fprintf(pfdebug, " \\x%02x", (unsigned char) *v);
|
||||||
else
|
else
|
||||||
fprintf(pfdebug, " %c", *v);
|
fprintf(pfdebug, " %c", *v);
|
||||||
*cursor += 1;
|
*cursor += 1;
|
||||||
@@ -212,7 +212,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char *data, int *cursor, bool s
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fwrite(v + next, 1, i - next, pfdebug);
|
fwrite(v + next, 1, i - next, pfdebug);
|
||||||
fprintf(pfdebug, "\\x%02x", v[i]);
|
fprintf(pfdebug, "\\x%02x", (unsigned char) v[i]);
|
||||||
next = i + 1;
|
next = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user