* [PATCH] lnstat: Fix deref of null in print_json() function @ 2024-01-06 19:04 Maks Mishin 2024-01-06 22:10 ` Stephen Hemminger 2024-01-08 17:40 ` patchwork-bot+netdevbpf 0 siblings, 2 replies; 3+ messages in thread From: Maks Mishin @ 2024-01-06 19:04 UTC (permalink / raw) To: Stephen Hemminger; +Cc: Maks Mishin, netdev Now pointer `jw` is being checked for NULL before using in function `jsonw_start_object`. Added exit from function when `jw==NULL`. Found by RASU JSC Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> --- misc/lnstat.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/lnstat.c b/misc/lnstat.c index c3f2999c..f802a0f3 100644 --- a/misc/lnstat.c +++ b/misc/lnstat.c @@ -112,6 +112,10 @@ static void print_json(FILE *of, const struct lnstat_file *lnstat_files, json_writer_t *jw = jsonw_new(of); int i; + if (jw == NULL) { + fprintf(stderr, "Failed to create JSON writer\n"); + exit(1); + } jsonw_start_object(jw); for (i = 0; i < fp->num; i++) { const struct lnstat_field *lf = fp->params[i].lf; -- 2.34.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lnstat: Fix deref of null in print_json() function 2024-01-06 19:04 [PATCH] lnstat: Fix deref of null in print_json() function Maks Mishin @ 2024-01-06 22:10 ` Stephen Hemminger 2024-01-08 17:40 ` patchwork-bot+netdevbpf 1 sibling, 0 replies; 3+ messages in thread From: Stephen Hemminger @ 2024-01-06 22:10 UTC (permalink / raw) To: Maks Mishin; +Cc: netdev On Sat, 6 Jan 2024 22:04:23 +0300 Maks Mishin <maks.mishinfz@gmail.com> wrote: > Now pointer `jw` is being checked for NULL before using > in function `jsonw_start_object`. > Added exit from function when `jw==NULL`. > > Found by RASU JSC > > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> Probably not worth fixing. If the malloc() of 20 bytes ever fails then something is really wrong. The Linux kernel will kill the process first. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lnstat: Fix deref of null in print_json() function 2024-01-06 19:04 [PATCH] lnstat: Fix deref of null in print_json() function Maks Mishin 2024-01-06 22:10 ` Stephen Hemminger @ 2024-01-08 17:40 ` patchwork-bot+netdevbpf 1 sibling, 0 replies; 3+ messages in thread From: patchwork-bot+netdevbpf @ 2024-01-08 17:40 UTC (permalink / raw) To: Maks Mishin; +Cc: stephen, maks.mishinFZ, netdev Hello: This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <stephen@networkplumber.org>: On Sat, 6 Jan 2024 22:04:23 +0300 you wrote: > Now pointer `jw` is being checked for NULL before using > in function `jsonw_start_object`. > Added exit from function when `jw==NULL`. > > Found by RASU JSC > > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> > > [...] Here is the summary with links: - lnstat: Fix deref of null in print_json() function https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=a193733b7a7e You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-08 17:40 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-01-06 19:04 [PATCH] lnstat: Fix deref of null in print_json() function Maks Mishin 2024-01-06 22:10 ` Stephen Hemminger 2024-01-08 17:40 ` patchwork-bot+netdevbpf
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 NNTP newsgroup(s).