Prevent normalize() from reading into undefined memory
PATCH 1/1 Prevent normalize() from reading into undefined memory
The current implementation does not account for a trailing backslash followed by a null-byte. If a null-byte is encountered following a backslash, normalize() will continue reading (and potentially writing) into garbage memory ignoring the EOS null-byte.
--- tools/perf/util/expr.l | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/expr.l +4 -1
@@ -42,8 +42,11 @@ static char *normalize(char *str, int runtime) char *dst = str; while (*str) { - if (*str == '\\') + if (*str == '\\') { *dst++ = *++str; + if (!*str) + break; + } else if (*str == '?') { char *paramval; int i = 0;
Signature · 1 line
2.38.1
Quoted 8 lines · Sohom Datta
The current implementation does not account for a trailing backslash followed by a null-byte. If a null-byte is encountered following a backslash,
normalize()will continue reading (and potentially writing) into garbage memory ignoring the EOS null-byte.Signed-off-by Sohom Datta <[email protected]>
thanks,
jirka
Quoted 24 lines
--- tools/perf/util/expr.l | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/perf/util/expr.l +4
-1@@ -42,8 +42,11 @@ static char *normalize(char *str, int runtime) char *dst = str; while (*str) { - if (*str == '\\') + if (*str == '\\') { *dst++ = *++str; + if (!*str) + break; + } else if (*str == '?') { char *paramval; int i = 0;Signature · 1 line
2.38.1
A message that is not in the archive (sent off-list or not yet received): CAP-5=fUjto38BaJX+Uj-BUOc74vg5KqZFewVCuUTW81Q=PAXHA@mail.gmail.com
Em Sun, Jan 08, 2023 at 04:55:59PM -0800, Ian Rogers escreveu:
Quoted 12 lines · Jiri Olsa
Quoted 11 lines · Sohom Datta
Quoted 8 lines
The current implementation does not account for a trailing backslash followed by a null-byte. If a null-byte is encountered following a backslash,
normalize()will continue reading (and potentially writing) into garbage memory ignoring the EOS null-byte.Signed-off-by Sohom Datta <[email protected]>
Quoted 7 lines
Quoted 5 lines
Acked-by Jiri Olsa <[email protected]>thanks,
jirkaAcked-by Ian Rogers <[email protected]>
Thanks, applied. Sorry for the delay, probably I didn't saw the "perf
tools: ' prefix in the subject and this fell thru the cracks :-\
Thanks to Ingo for pinging me about this, appreciated.
- Arnaldo
Quoted 28 lines
Thanks,
IanQuoted 25 lines
---
Quoted 23 lines
tools/perf/util/expr.l | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/perf/util/expr.l +4
-2@@ -42,8 +42,11 @@ static char *normalize(char *str, int runtime) char *dst = str; while (*str) { - if (*str == '\\') + if (*str == '\\') { *dst++ = *++str; + if (!*str) + break; + } else if (*str == '?') { char *paramval; int i = 0; --2.38.1