diff options
author | Joe Conway <mail@joeconway.com> | 2003-11-30 20:53:43 +0000 |
---|---|---|
committer | Joe Conway <mail@joeconway.com> | 2003-11-30 20:53:43 +0000 |
commit | 10b84be9b347bb6ab587719301bbb72ea5f5c78a (patch) | |
tree | 11d0483abe98818fb38acac75d03a81d295dd39f /src/interfaces/libpq/fe-exec.c | |
parent | 1adcaadc2f326f4873581fe56d424f6e2729e654 (diff) | |
download | postgresql-10b84be9b347bb6ab587719301bbb72ea5f5c78a.tar.gz postgresql-10b84be9b347bb6ab587719301bbb72ea5f5c78a.zip |
Make PQescapeBytea and byteaout consistent with each other, and
octal escape all octets outside the range 0x20 to 0x7e. This fixes
the problem pointed out by Sergey Yatskevich here:
http://archives.postgresql.org/pgsql-bugs/2003-11/msg00140.php
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index d25943ee111..03fec88e677 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.153 2003/10/31 17:43:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.153.2.1 2003/11/30 20:53:43 joe Exp $ * *------------------------------------------------------------------------- */ @@ -2261,7 +2261,8 @@ PQescapeString(char *to, const char *from, size_t length) * '\0' == ASCII 0 == \\000 * '\'' == ASCII 39 == \' * '\\' == ASCII 92 == \\\\ - * anything >= 0x80 ---> \\ooo (where ooo is an octal expression) + * anything < 0x20, or > 0x7e ---> \\ooo + * (where ooo is an octal expression) */ unsigned char * PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen) @@ -2280,7 +2281,7 @@ PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen) vp = bintext; for (i = binlen; i > 0; i--, vp++) { - if (*vp == 0 || *vp >= 0x80) + if (*vp < 0x20 || *vp > 0x7e) len += 5; /* '5' is for '\\ooo' */ else if (*vp == '\'') len += 2; @@ -2299,7 +2300,7 @@ PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen) for (i = binlen; i > 0; i--, vp++) { - if (*vp == 0 || *vp >= 0x80) + if (*vp < 0x20 || *vp > 0x7e) { (void) sprintf(rp, "\\\\%03o", *vp); rp += 5; |