pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c444472af5c202067a9ecb0ff8df7370fb1ea8f4

Modified Files
--------------
src/backend/commands/copyfromparse.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c87cbd51ee1d8e3486cab9bf8db2f026595bd77d

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9b0ce895794c88b6556d6990cdf13e8da35d11de

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d9b4163c553eb8ae47034946c11efb04e9498f6f

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c06632e48b3537f9a062f6c4686a730625a429fd

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e152ccc7fd5932cfa9371a7c4cb7ca9a7733c5ab

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix backslash-escaping multibyte chars in COPY FROM.
@ 2021-02-05 09:58 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2021-02-05 09:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backslash-escaping multibyte chars in COPY FROM.

If a multi-byte character is escaped with a backslash in TEXT mode input,
and the encoding is one of the client-only encodings where the bytes after
the first one can have an ASCII byte "embedded" in the char, we didn't
skip the character correctly. After a backslash, we only skipped the first
byte of the next character, so if it was a multi-byte character, we would
try to process its second byte as if it was a separate character. If it
was one of the characters with special meaning, like '\n', '\r', or
another '\\', that would cause trouble.

One such exmple is the byte sequence '\x5ca45c2e666f6f' in Big5 encoding.
That's supposed to be [backslash][two-byte character][.][f][o][o], but
because the second byte of the two-byte character is 0x5c, we incorrectly
treat it as another backslash. And because the next character is a dot, we
parse it as end-of-copy marker, and throw an "end-of-copy marker corrupt"
error.

Backpatch to all supported versions.

Reviewed-by: John Naylor, Kyotaro Horiguchi
Discussion: https://www.postgresql.org/message-id/a897f84f-8dca-8798-3139-07da5bb38728%40iki.fi

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/aaf266157d21935d8106bd68c18eadea5dfdf1eb

Modified Files
--------------
src/backend/commands/copy.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2021-02-05 09:58 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-02-05 09:58 pgsql: Fix backslash-escaping multibyte chars in COPY FROM. Heikki Linnakangas <heikki.linnakangas@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox