diff mbox series

[3/8] inet/rcmd.c: fix warn unused result

Message ID 20230418121130.844302-4-fberat@redhat.com
State New
Headers show
Series Fix warn unused result | expand

Commit Message

Frederic Berat April 18, 2023, 12:11 p.m. UTC
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
---
 inet/rcmd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Siddhesh Poyarekar April 18, 2023, 12:37 p.m. UTC | #1
On 2023-04-18 08:11, Frédéric Bérat via Libc-alpha wrote:
> Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
> glibc.
> ---
>   inet/rcmd.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> 
> diff --git a/inet/rcmd.c b/inet/rcmd.c
> index ad8a894907..c1cd9daeb5 100644
> --- a/inet/rcmd.c
> +++ b/inet/rcmd.c
> @@ -561,7 +561,9 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>   	  reading an NFS mounted file system, can't read files that
>   	  are protected read/write owner only.  */
>          uid = __geteuid ();
> -       seteuid (pwd->pw_uid);
> +       if (seteuid (pwd->pw_uid) < 0)
> +	       return -1;
> +
>          hostf = iruserfopen (pbuf, pwd->pw_uid);
>   
>          if (hostf != NULL)
> @@ -570,7 +572,8 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>   	   fclose (hostf);
>   	 }
>   
> -       seteuid (uid);
> +       if (seteuid (uid) < 0)
> +	       return -1;
>          return isbad;
>       }
>     return -1;
Andreas Schwab April 18, 2023, 1:40 p.m. UTC | #2
On Apr 18 2023, Frédéric Bérat via Libc-alpha wrote:

> diff --git a/inet/rcmd.c b/inet/rcmd.c
> index ad8a894907..c1cd9daeb5 100644
> --- a/inet/rcmd.c
> +++ b/inet/rcmd.c
> @@ -561,7 +561,9 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>  	  reading an NFS mounted file system, can't read files that
>  	  are protected read/write owner only.  */
>         uid = __geteuid ();
> -       seteuid (pwd->pw_uid);
> +       if (seteuid (pwd->pw_uid) < 0)
> +	       return -1;

Wrong indentation.

> @@ -570,7 +572,8 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>  	   fclose (hostf);
>  	 }
>  
> -       seteuid (uid);
> +       if (seteuid (uid) < 0)
> +	       return -1;

Wrong indentation.
Siddhesh Poyarekar April 18, 2023, 1:50 p.m. UTC | #3
On 2023-04-18 09:40, Andreas Schwab wrote:
> On Apr 18 2023, Frédéric Bérat via Libc-alpha wrote:
> 
>> diff --git a/inet/rcmd.c b/inet/rcmd.c
>> index ad8a894907..c1cd9daeb5 100644
>> --- a/inet/rcmd.c
>> +++ b/inet/rcmd.c
>> @@ -561,7 +561,9 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>>   	  reading an NFS mounted file system, can't read files that
>>   	  are protected read/write owner only.  */
>>          uid = __geteuid ();
>> -       seteuid (pwd->pw_uid);
>> +       if (seteuid (pwd->pw_uid) < 0)
>> +	       return -1;
> 
> Wrong indentation.
> 
>> @@ -570,7 +572,8 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
>>   	   fclose (hostf);
>>   	 }
>>   
>> -       seteuid (uid);
>> +       if (seteuid (uid) < 0)
>> +	       return -1;
> 
> Wrong indentation.
> 

Oops, I pushed an obvious change fixing that.

Thanks,
Sid
diff mbox series

Patch

diff --git a/inet/rcmd.c b/inet/rcmd.c
index ad8a894907..c1cd9daeb5 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -561,7 +561,9 @@  ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
 	  reading an NFS mounted file system, can't read files that
 	  are protected read/write owner only.  */
        uid = __geteuid ();
-       seteuid (pwd->pw_uid);
+       if (seteuid (pwd->pw_uid) < 0)
+	       return -1;
+
        hostf = iruserfopen (pbuf, pwd->pw_uid);
 
        if (hostf != NULL)
@@ -570,7 +572,8 @@  ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser,
 	   fclose (hostf);
 	 }
 
-       seteuid (uid);
+       if (seteuid (uid) < 0)
+	       return -1;
        return isbad;
     }
   return -1;