* [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " "
@ 2022-04-21 10:47 Ilya Leoshkevich
2022-04-21 11:18 ` Bruno Larsen
2022-04-21 11:23 ` Ilya Leoshkevich
0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2022-04-21 10:47 UTC (permalink / raw)
To: gdb-patches; +Cc: Andreas Arnez, Ilya Leoshkevich
Exit early if find_first_not_of returns npos - passing npos to
substr leads to an exception.
---
gdb/debuginfod-support.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 6c2d3fb2951..668c50c405c 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -187,10 +187,13 @@ debuginfod_is_enabled ()
gdb::string_view url_view (urls);
while (true)
{
- url_view = url_view.substr (url_view.find_first_not_of (' '));
+ size_t off = url_view.find_first_not_of (' ');
+ if (off == gdb::string_view::npos)
+ break;
+ url_view = url_view.substr (off);
if (url_view.empty ())
break;
- size_t off = url_view.find_first_of (' ');
+ off = url_view.find_first_of (' ');
gdb_printf
(_(" <%ps>\n"),
styled_string (file_name_style.style (),
--
2.35.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " "
2022-04-21 10:47 [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " " Ilya Leoshkevich
@ 2022-04-21 11:18 ` Bruno Larsen
2022-04-21 11:23 ` Ilya Leoshkevich
1 sibling, 0 replies; 3+ messages in thread
From: Bruno Larsen @ 2022-04-21 11:18 UTC (permalink / raw)
To: gdb-patches
Ilya hello!
On 4/21/22 07:47, Ilya Leoshkevich via Gdb-patches wrote:
> Exit early if find_first_not_of returns npos - passing npos to
> substr leads to an exception.
Thank you for looking at this! A patch exactly like yours has been pushed just 12 hours before you sent this in (https://sourceware.org/pipermail/gdb-patches/2022-April/187688.html)
> ---
> gdb/debuginfod-support.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 6c2d3fb2951..668c50c405c 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -187,10 +187,13 @@ debuginfod_is_enabled ()
> gdb::string_view url_view (urls);
> while (true)
> {
> - url_view = url_view.substr (url_view.find_first_not_of (' '));
> + size_t off = url_view.find_first_not_of (' ');
> + if (off == gdb::string_view::npos)
> + break;
> + url_view = url_view.substr (off);
> if (url_view.empty ())
> break;
> - size_t off = url_view.find_first_of (' ');
> + off = url_view.find_first_of (' ');
> gdb_printf
> (_(" <%ps>\n"),
> styled_string (file_name_style.style (),
Cheers!
Bruno Larsen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " "
2022-04-21 10:47 [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " " Ilya Leoshkevich
2022-04-21 11:18 ` Bruno Larsen
@ 2022-04-21 11:23 ` Ilya Leoshkevich
1 sibling, 0 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2022-04-21 11:23 UTC (permalink / raw)
To: gdb-patches; +Cc: Andreas Arnez
On Thu, 2022-04-21 at 12:47 +0200, Ilya Leoshkevich wrote:
> Exit early if find_first_not_of returns npos - passing npos to
> substr leads to an exception.
> ---
> gdb/debuginfod-support.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
> index 6c2d3fb2951..668c50c405c 100644
> --- a/gdb/debuginfod-support.c
> +++ b/gdb/debuginfod-support.c
> @@ -187,10 +187,13 @@ debuginfod_is_enabled ()
> gdb::string_view url_view (urls);
> while (true)
> {
> - url_view = url_view.substr (url_view.find_first_not_of ('
> '));
> + size_t off = url_view.find_first_not_of (' ');
> + if (off == gdb::string_view::npos)
> + break;
> + url_view = url_view.substr (off);
> if (url_view.empty ())
> break;
> - size_t off = url_view.find_first_of (' ');
> + off = url_view.find_first_of (' ');
> gdb_printf
> (_(" <%ps>\n"),
> styled_string (file_name_style.style (),
Please disregard this patch - I just noticed that this is already fixed
by https://sourceware.org/pipermail/gdb-patches/2022-April/187688.html
Best regards,
Ilya
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-21 11:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 10:47 [PATCH] gdb/debuginfod-support.c: Do not crash if URL list is " " Ilya Leoshkevich
2022-04-21 11:18 ` Bruno Larsen
2022-04-21 11:23 ` Ilya Leoshkevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).