forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit54549d8
committed
> I found a problem with PQescapeString (I think). Since it escapes
> null bytes to be literally '\0', the following can happen:> 1. User inputs string value as "<null byte>##" where ## are digits in the> range of 0 to 7.> 2. PQescapeString converts this to "\0##"> 3. Escaped string is used in a context that causes "\0##" to be evaluated as> an octal escape sequence.I agree that this is a problem, though it is not possible to doanything harmful with it. In addition, it only occurs if there areany NUL characters in its input, which is very unlikely if you areusing C strings.The patch below addresses the issue by removing escaping of \0characters entirely.> If the goal is to "safely" encode null bytes, and preserve the rest of the> string as it was entered, I think the null bytes should be escaped as \\000> (note that if you simply use \000 the same string truncation problem> occurs).We can't do that, this would require 4n + 1 bytes of storage for theresult, breaking the interface.Florian Weimer1 parent351a0c1 commit54549d8
File tree
2 files changed
+3
-10
lines changed- src/interfaces
- jdbc/org/postgresql/jdbc2
- libpq
2 files changed
+3
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1396 | 1396 | | |
1397 | 1397 | | |
1398 | 1398 | | |
1399 | | - | |
| 1399 | + | |
1400 | 1400 | | |
1401 | 1401 | | |
1402 | 1402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 78 | | |
86 | 79 | | |
87 | 80 | | |
| |||
0 commit comments
Comments
(0)