diff mbox series

[testsuite] tests/sctp: initialize addrlen for accept(2) properly

Message ID 20191112154929.24292-1-omosnace@redhat.com (mailing list archive)
State Accepted
Headers show
Series [testsuite] tests/sctp: initialize addrlen for accept(2) properly | expand

Commit Message

Ondrej Mosnacek Nov. 12, 2019, 3:49 p.m. UTC
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(+)

Comments

Stephen Smalley Nov. 12, 2019, 4:18 p.m. UTC | #1
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");
>
Stephen Smalley Nov. 14, 2019, 1:39 p.m. UTC | #2
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");
>
diff mbox series

Patch

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");