From: Petr Vorel <pvorel@suse.cz>
To: Hongchen Zhang <zhanghongchen@loongson.cn>
Cc: libtirpc-devel@lists.sourceforge.net, ltp@lists.linux.it,
Steve Dickson <steved@redhat.com>
Subject: Re: [LTP] [PATCH] rpc01: fix variable not initialized
Date: Mon, 11 Jul 2022 08:09:29 +0200 [thread overview]
Message-ID: <Ysu+mbkO8eUP4A2+@pevik> (raw)
In-Reply-To: <1656937069-17098-1-git-send-email-zhanghongchen@loongson.cn>
Hi all,
[ Cc Steve and libtirpc-devel ML ]
> when error occurred in function callrpc/clnt_call, return_buffer may
> be leaved not initialized.So initialize return_buffer to NULL,and
> retrieve the return_buffer->data when return_buffer is really assigned.
Shouldn't be rc used for verification?
man callrpc(3):
int callrpc(...);
...
This routine returns zero if it succeeds, or the value of enum clnt_stat cast to
an integer if it fails. The routine clnt_perrno() is handy for translating
failure statuses into messages.
Kind regards,
Petr
> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
> ---
> testcases/network/rpc/basic_tests/rpc01/rpc1.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
> diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc1.c b/testcases/network/rpc/basic_tests/rpc01/rpc1.c
> index bc9f35b..5691c06 100644
> --- a/testcases/network/rpc/basic_tests/rpc01/rpc1.c
> +++ b/testcases/network/rpc/basic_tests/rpc01/rpc1.c
> @@ -24,7 +24,7 @@ void usage_error(char *program_name);
> int main(int argc, char *argv[])
> {
> struct hostent *hp;
> - struct data buffer, *return_buffer;
> + struct data buffer, *return_buffer = NULL;
> int i, n, rc;
> FILE *fp;
> struct stat stat_buffer;
> @@ -128,7 +128,8 @@ int main(int argc, char *argv[])
> rc = callrpc(server, program, version, 1, (xdrproc_t)xdr_send_data,
> (char *)&buffer, (xdrproc_t)xdr_receive_data,
> (char *)&return_buffer);
> - do_compare(rc, "callrpc", &buffer, return_buffer->data);
> + do_compare(rc, "callrpc", &buffer,
> + return_buffer ? return_buffer->data : NULL);
> server_sin.sin_port = 0;
> sock = RPC_ANYSOCK;
> @@ -145,7 +146,8 @@ int main(int argc, char *argv[])
> (char *)&buffer, (xdrproc_t)xdr_receive_data,
> (char *)&return_buffer, timeout);
> clnt_destroy(clnt);
> - do_compare(rc, "udp transport", &buffer, return_buffer->data);
> + do_compare(rc, "udp transport", &buffer,
> + return_buffer ? return_buffer->data : NULL);
> server_sin.sin_port = 0;
> sock = RPC_ANYSOCK;
> @@ -160,7 +162,8 @@ int main(int argc, char *argv[])
> (char *)&buffer, (xdrproc_t)xdr_receive_data,
> (char *)&return_buffer, timeout);
> clnt_destroy(clnt);
> - do_compare(rc, "tcp transport", &buffer, return_buffer->data);
> + do_compare(rc, "tcp transport", &buffer,
> + return_buffer ? return_buffer->data : NULL);
> exit(0);
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-07-11 6:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 12:17 [LTP] [PATCH] rpc01: fix variable not initialized Hongchen Zhang
2022-07-11 6:09 ` Petr Vorel [this message]
2022-07-12 6:43 ` [LTP] [PATCH v2] " Hongchen Zhang
2022-10-10 13:23 ` Richard Palethorpe
2022-10-10 14:40 ` Petr Vorel
2022-10-11 8:36 ` Richard Palethorpe
2022-10-11 8:50 ` Petr Vorel
2022-07-12 6:46 ` Hongchen Zhang
2022-07-12 7:01 ` [LTP] [PATCH] " Hongchen Zhang
-- strict thread matches above, loose matches on Subject: below --
2022-07-04 12:08 Hongchen Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ysu+mbkO8eUP4A2+@pevik \
--to=pvorel@suse.cz \
--cc=libtirpc-devel@lists.sourceforge.net \
--cc=ltp@lists.linux.it \
--cc=steved@redhat.com \
--cc=zhanghongchen@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox