Re: [PATCH 2/5] login: use xalloc lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 29, 2010 at 09:27:11AM -0300, Davidlohr Bueso wrote:
> 
> From: Davidlohr Bueso <dave@xxxxxxx>
> 
> Signed-off-by: Davidlohr Bueso <dave@xxxxxxx>
> ---
>  login-utils/login.c |    9 ++-------
>  1 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/login-utils/login.c b/login-utils/login.c
> index 68eb84b..1802d3a 100644
> --- a/login-utils/login.c
> +++ b/login-utils/login.c
> @@ -115,7 +115,7 @@
>  #include "login.h"
>  #include "strutils.h"
>  #include "nls.h"
> -
> +#include "xalloc.h"
>  
>  #ifdef HAVE_SECURITY_PAM_MISC_H
>  #  include <security/pam_appl.h>
> @@ -1240,12 +1240,7 @@ Michael Riepe <michael@xxxxxxxxxxxxxxxxxxxx>
>  
>      /* if the shell field has a space: treat it like a shell script */
>      if (strchr(pwd->pw_shell, ' ')) {
> -	buff = malloc(strlen(pwd->pw_shell) + 6);
> -
> -	if (!buff) {
> -	    fprintf(stderr, _("login: no memory for shell script.\n"));
> -	    exit(0);
> -	}
> +	buff = xmalloc(strlen(pwd->pw_shell) + 6);

 Applied, but note that xmalloc() returns '1' on error and login was
 exit(0) here. Fortunately, login uses '1' on errors too.

 It would be nice to clean up login return codes (use EXIT_* macros).

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux