psql_encoding_bugfix.patch
application/octet-stream
Filename: psql_encoding_bugfix.patch
Type: application/octet-stream
Part: 0
Message:
psql crashes on encoding mismatch
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/bin/psql/psqlscan.l | 2 | 1 |
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l index 3575f91..218d7e0 100644 --- a/src/bin/psql/psqlscan.l +++ b/src/bin/psql/psqlscan.l @@ -1775,7 +1775,8 @@ prepare_buffer(const char *txt, int len, char **txtcopy) /* first byte should always be okay... */ newtxt[i] = txt[i]; i++; - while (--thislen > 0) + /* thislen might be greater than len, so double-check */ + while (--thislen > 0 && i < len) newtxt[i++] = (char) 0xFF; } }