[LTP] [PATCH] getsockname01: Add case for errno EINVAL

Petr Vorel pvorel@suse.cz
Thu May 16 03:43:00 CEST 2024


Hi Xu,

...
> +++ b/testcases/kernel/syscalls/getsockname/getsockname01.c
> @@ -12,6 +12,7 @@
>   * - EBADF on a not open file
>   * - ENOTSOCK on a file descriptor not linked to a socket
>   * - EFAULT on invalid socket buffer o invalid socklen
> + * - EINVALI on an invalid addrlen
>   */

>  #include "tst_test.h"
> @@ -19,6 +20,7 @@
>  static struct sockaddr_in sin0, fsin1;
>  static int sock_null, sock_bind, sock_fake;
>  static socklen_t sinlen;
> +static socklen_t sininval;

Merged with following changes:

static socklen_t sininval = -1;


>  static struct test_case {
>  	int *sock;
> @@ -37,6 +39,8 @@ static struct test_case {
>  		.experrno = EFAULT, "invalid aligned salen"},
>  	{ .sock = &sock_bind, .sockaddr = &fsin1, .addrlen = (socklen_t *) 1,
>  		.experrno = EFAULT, "invalid unaligned salen"},
> +	{ .sock = &sock_bind, .sockaddr = &fsin1, .addrlen = &sininval,
> +		.experrno = EINVAL, "invalid socklen"},
>  };

>  static void check_getsockname(unsigned int nr)
> @@ -57,6 +61,7 @@ static void setup(void)
>  	sock_bind = SAFE_SOCKET(PF_INET, SOCK_STREAM, 0);
>  	SAFE_BIND(sock_bind, (struct sockaddr *)&sin0, sizeof(sin0));
>  	sinlen = sizeof(sin0);
> +	sininval = -1;

and thus removed it here.

Thanks!

Kind regards,
Petr


More information about the ltp mailing list