Commit b720cc2
committed
[1223] Change FormattedMessage pattern heuristic
We change the order in which `FormattedMessage` checks the format of the
provided pattern: we first check for the presence of `{}` placeholders
and only then for `java.util.Format` specifiers.
This eliminates the need for a potentially exponential regular
expression evalutation, which was reported by Spotbugs (#1849).
The Javadoc and documentation were improved to clarify the heuristic
used by `FormattedMessage`.
Closes #1223.
Remark: since `FormattedMessage` used the **same** regular expression as
`java.util.Format`, if a message uses `java.util.Format` specifiers, it
is still vulnerable to a ReDOS.1 parent 8c92ffe commit b720cc2
File tree
2 files changed
+37
-11
lines changed- log4j-api/src/main/java/org/apache/logging/log4j/message
- src/changelog/.3.x.x
2 files changed
+37
-11
lines changedLines changed: 26 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 32 | | |
37 | 33 | | |
38 | 34 | | |
| |||
168 | 164 | | |
169 | 165 | | |
170 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
171 | 186 | | |
| 187 | + | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
| |||
178 | 194 | | |
179 | 195 | | |
180 | 196 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
187 | 201 | | |
188 | | - | |
| 202 | + | |
| 203 | + | |
189 | 204 | | |
190 | 205 | | |
191 | 206 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments