[Crash-utility] [PATCH] Fix for "net -n" option to properly deal with invalid arguments
HAGIO KAZUHITO(萩尾 一仁)
k-hagio-ab at nec.com
Thu Mar 9 04:47:36 UTC 2023
On 2023/03/08 21:22, Lianbo Jiang wrote:
> The help/man page of the "net" command suggests that "-n" option can
> accept two valid arguments: PID or task_struct pointer. However, the
> "net -n" command accepts invalid arguments and shows a bogus result.
> For example:
>
> crash> net -n 1000000000
> NET_DEVICE NAME IP ADDRESS(ES)
> ffff949dc11d7000 lo 127.0.0.1
> ffff949dcc01c000 eno49 192.168.122.17
>
> In fact, when an invalid argument is entered, it always outputs the
> network namespace of a current contex. This is not expected.
>
> With the patch:
> crash> net -n 1000000000
> net: invalid task or pid value: 1000000000
>
> Reported-by: Buland Kumar Singh <bsingh at redhat.com>
> Signed-off-by: Lianbo Jiang <lijiang at redhat.com>
Looks good. Applied with a few expression changes in the commit log.
https://github.com/crash-utility/crash/commit/5a652ed0c8db8d4c5891091b747470431054c717
Thanks,
Kazu
> ---
> net.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net.c b/net.c
> index 987dc8934942..18c238be346d 100644
> --- a/net.c
> +++ b/net.c
> @@ -420,6 +420,9 @@ cmd_net(void)
> case STR_PID:
> case STR_TASK:
> task = tc->task;
> + break;
> + case STR_INVALID:
> + error(FATAL, "invalid task or pid value: %s\n", args[optind]);
> }
> }
> break;
More information about the Crash-utility
mailing list