Re: [PATCH] Fix for "net -n" option to properly deal with invalid arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx>

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;
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux