Re: [PATCH] Fix comparison between two character arrays

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Jul 27 11:02, Jordi Sanfeliu wrote:
> 
> Hello,
> 
> The member 'id' in the 'utmp' struct is not a numeric but a character array,
> hence the strncmp() function is needed to compare two members.
> 
> diff --git a/newlib/libc/unix/getut.c b/newlib/libc/unix/getut.c
> index 89ed739..71a8c8f 100644
> --- a/newlib/libc/unix/getut.c
> +++ b/newlib/libc/unix/getut.c
> @@ -63,7 +63,7 @@ getutid (struct utmp *id)
>  	case LOGIN_PROCESS:
>  	case USER_PROCESS:
>  	case DEAD_PROCESS:
> -	  if (id->ut_id == utmp_data.ut_id)
> +	  if (!strncmp (id->ut_id, utmp_data.ut_id, sizeof (utmp_data.ut_id)))
>  	    return &utmp_data;
>  	  break;
>  	default:
> 
> Thanks.
> 
> --
> Jordi Sanfeliu
> FIBRANET Network Services Provider
> https://www.fibranet.cat

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAltewEIACgkQ9TYGna5E
T6B5QBAAmchWtr9yr2n8x2PQ7Uioo7RVEndFYMuIHSvXWBA++2T6MVwgni/Chu+I
L4goXBEfA+bpp07NPrN02iSyvoHjaiOXvJLucc2rDYq3OJ876BaXLoBPmpnKgCDv
yEm1eRWrFcTrtRQioWCq7WKZhwp6e6cpQpY1Z8l/gI2ImQAa2ZWcHyaRNeg5FfNT
spEVnT2yleHEF1p9lUGpyf5aQbbLbl4/ojC8OIwcacKb1drjNNHsfGlniYbt4omD
N2xNQxq3R4WYIhi3Ygh0L/tlzvZjU/TQQalj9xJWtOyzXWHPIj0IAt3zw90eebbZ
mwE6z31WsR7RsrxLLSDbr+Nl0jlXuNG53tHSu3b158PtxB/2XVJAWMXx9CpreXyk
19F/3KBYaQVwC8/MAWS0O2TCMxZ7F0b4RPVUMh82j/6urK1LhR1IER7uZezaSUj9
CPMfnFq5aoKJ1nn9Y1W97wb9Yaf2mrA8clDSZJQ0XsVS6crEdrywO+UY1TOcl7Vo
g3TtLLVfdPGMuTXRjlcYR+GpVtfWjHY8MuzbBAxpqZyZsE+CXZZpuHeNbKWv85op
WN4ayvC9pQ+blcdJ3XFAHkKH9M4N3iaREF9vHXX7aNArk2ofnYL5Jd82U5STZVqM
UPl+al547AhEIOMCH3STj6LpP08wvO1jInIDS7P0WDU/OJTPLPY=
=MTyr
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.