selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly
@ 2019-11-12 15:49 Ondrej Mosnacek
  2019-11-12 16:18 ` Stephen Smalley
  2019-11-14 13:39 ` Stephen Smalley
  0 siblings, 2 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2019-11-12 15:49 UTC (permalink / raw)
  To: selinux

The 'addrlen' argument of accept(2) must point to a variable containing
the size of the structure pointed to by 'addr'. In some cases it was
being left unitialized. Fix this.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 tests/sctp/sctp_asconf_params_server.c | 1 +
 tests/sctp/sctp_set_peer_addr.c        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/tests/sctp/sctp_asconf_params_server.c b/tests/sctp/sctp_asconf_params_server.c
index 3333ba0..ff7473b 100644
--- a/tests/sctp/sctp_asconf_params_server.c
+++ b/tests/sctp/sctp_asconf_params_server.c
@@ -112,6 +112,7 @@ int main(int argc, char **argv)
 		fclose(f);
 	}
 
+	sinlen = sizeof(sin);
 	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
 	if (new_sock < 0) {
 		perror("accept");
diff --git a/tests/sctp/sctp_set_peer_addr.c b/tests/sctp/sctp_set_peer_addr.c
index 61a3a44..c35b518 100644
--- a/tests/sctp/sctp_set_peer_addr.c
+++ b/tests/sctp/sctp_set_peer_addr.c
@@ -277,6 +277,7 @@ int main(int argc, char **argv)
 		printf("Client peer address count: %d\n", peer_count);
 
 	/* Client and server now set so accept new socket on server side. */
+	sinlen = sizeof(sin);
 	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
 	if (new_sock < 0) {
 		perror("accept");
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly
  2019-11-12 15:49 [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly Ondrej Mosnacek
@ 2019-11-12 16:18 ` Stephen Smalley
  2019-11-14 13:39 ` Stephen Smalley
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2019-11-12 16:18 UTC (permalink / raw)
  To: Ondrej Mosnacek, selinux

On 11/12/19 10:49 AM, Ondrej Mosnacek wrote:
> The 'addrlen' argument of accept(2) must point to a variable containing
> the size of the structure pointed to by 'addr'. In some cases it was
> being left unitialized. Fix this.
> 
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Acked-by: Stephen Smalley <sds@tycho.nsa.gov>

> ---
>   tests/sctp/sctp_asconf_params_server.c | 1 +
>   tests/sctp/sctp_set_peer_addr.c        | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/tests/sctp/sctp_asconf_params_server.c b/tests/sctp/sctp_asconf_params_server.c
> index 3333ba0..ff7473b 100644
> --- a/tests/sctp/sctp_asconf_params_server.c
> +++ b/tests/sctp/sctp_asconf_params_server.c
> @@ -112,6 +112,7 @@ int main(int argc, char **argv)
>   		fclose(f);
>   	}
>   
> +	sinlen = sizeof(sin);
>   	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
>   	if (new_sock < 0) {
>   		perror("accept");
> diff --git a/tests/sctp/sctp_set_peer_addr.c b/tests/sctp/sctp_set_peer_addr.c
> index 61a3a44..c35b518 100644
> --- a/tests/sctp/sctp_set_peer_addr.c
> +++ b/tests/sctp/sctp_set_peer_addr.c
> @@ -277,6 +277,7 @@ int main(int argc, char **argv)
>   		printf("Client peer address count: %d\n", peer_count);
>   
>   	/* Client and server now set so accept new socket on server side. */
> +	sinlen = sizeof(sin);
>   	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
>   	if (new_sock < 0) {
>   		perror("accept");
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly
  2019-11-12 15:49 [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly Ondrej Mosnacek
  2019-11-12 16:18 ` Stephen Smalley
@ 2019-11-14 13:39 ` Stephen Smalley
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2019-11-14 13:39 UTC (permalink / raw)
  To: Ondrej Mosnacek, selinux

On 11/12/19 10:49 AM, Ondrej Mosnacek wrote:
> The 'addrlen' argument of accept(2) must point to a variable containing
> the size of the structure pointed to by 'addr'. In some cases it was
> being left unitialized. Fix this.
> 
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Thanks, applied.

> ---
>   tests/sctp/sctp_asconf_params_server.c | 1 +
>   tests/sctp/sctp_set_peer_addr.c        | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/tests/sctp/sctp_asconf_params_server.c b/tests/sctp/sctp_asconf_params_server.c
> index 3333ba0..ff7473b 100644
> --- a/tests/sctp/sctp_asconf_params_server.c
> +++ b/tests/sctp/sctp_asconf_params_server.c
> @@ -112,6 +112,7 @@ int main(int argc, char **argv)
>   		fclose(f);
>   	}
>   
> +	sinlen = sizeof(sin);
>   	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
>   	if (new_sock < 0) {
>   		perror("accept");
> diff --git a/tests/sctp/sctp_set_peer_addr.c b/tests/sctp/sctp_set_peer_addr.c
> index 61a3a44..c35b518 100644
> --- a/tests/sctp/sctp_set_peer_addr.c
> +++ b/tests/sctp/sctp_set_peer_addr.c
> @@ -277,6 +277,7 @@ int main(int argc, char **argv)
>   		printf("Client peer address count: %d\n", peer_count);
>   
>   	/* Client and server now set so accept new socket on server side. */
> +	sinlen = sizeof(sin);
>   	new_sock = accept(srv_sock, (struct sockaddr *)&sin, &sinlen);
>   	if (new_sock < 0) {
>   		perror("accept");
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-14 13:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 15:49 [PATCH testsuite] tests/sctp: initialize addrlen for accept(2) properly Ondrej Mosnacek
2019-11-12 16:18 ` Stephen Smalley
2019-11-14 13:39 ` Stephen Smalley

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).