* [PATCH iproute2] ss: fix NULL dereference when rendering without header
@ 2018-03-03 16:59 Jean-Philippe Brucker
2018-03-03 17:35 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Jean-Philippe Brucker @ 2018-03-03 16:59 UTC (permalink / raw)
To: stephen; +Cc: netdev
When ss is invoked with the no-header flag, if the query doesn't return
any result, render() is called with 'buffer' uninitialized. This
currently leads to a segfault. Ensure that buffer is initialized before
rendering.
The bug can be triggered with: ss -H sport = 100000
Signed-off-by: Jean-Philippe Brucker <jphilippe.brucker@gmail.com>
---
misc/ss.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/misc/ss.c b/misc/ss.c
index e047f9c0..e087bef7 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1197,10 +1197,15 @@ newline:
/* Render buffered output with spacing and delimiters, then free up buffers */
static void render(int screen_width)
{
- struct buf_token *token = (struct buf_token *)buffer.head->data;
+ struct buf_token *token;
int printed, line_started = 0;
struct column *f;
+ if (!buffer.head)
+ return;
+
+ token = (struct buf_token *)buffer.head->data;
+
/* Ensure end alignment of last token, it wasn't necessarily flushed */
buffer.tail->end += buffer.cur->len % 2;
--
2.16.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ss: fix NULL dereference when rendering without header
2018-03-03 16:59 [PATCH iproute2] ss: fix NULL dereference when rendering without header Jean-Philippe Brucker
@ 2018-03-03 17:35 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2018-03-03 17:35 UTC (permalink / raw)
To: Jean-Philippe Brucker; +Cc: stephen, netdev
On Sat, 3 Mar 2018 16:59:44 +0000
Jean-Philippe Brucker <jphilippe.brucker@gmail.com> wrote:
> When ss is invoked with the no-header flag, if the query doesn't return
> any result, render() is called with 'buffer' uninitialized. This
> currently leads to a segfault. Ensure that buffer is initialized before
> rendering.
>
> The bug can be triggered with: ss -H sport = 100000
Oh dear. Nice catch, thanks for fixing this.
> Signed-off-by: Jean-Philippe Brucker <jphilippe.brucker@gmail.com>
Acked-by: Stefano Brivio <sbrivio@redhat.com>
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-03 17:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03 16:59 [PATCH iproute2] ss: fix NULL dereference when rendering without header Jean-Philippe Brucker
2018-03-03 17:35 ` Stefano Brivio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox